执行动作
接口说明
执行特定动作(如戳一下、抱抱等)。
请求信息
- Method:
POST - Path:
/v1/actions/execute - 认证: 需要
请求参数
json
{
"action_type": "string" // 动作类型,见动作类型表
}动作类型表
| 动作类型 | 名称 | 解锁条件 | 亲密度点数 | 冷却时间 | 备注 |
|---|---|---|---|---|---|
| morning_greeting | 早安问候 | 无 | +2 | 每日一次 | 06:00-10:00 |
| chat | 聊天 | 无 | +3 | 每日首次 | - |
| night_greeting | 晚安问候 | 无 | +2 | 每日一次 | 21:00-23:59 |
| check_status | 在干嘛 | 1级(陌生人) | +0 | 无 | - |
| poke | 戳一下 | 2级(普通朋友) | +1 | 无 | - |
| pinch | 捏捏脸 | 2级(普通朋友) | +1 | 无 | - |
| gift | 送礼物 | 2级(普通朋友) | +3 | 无 | - |
| confess | 表白 | 4级(挚友,401+分) | +0 | 失败后3天 | 关系触发型动作 |
| hug | 抱抱 | 需要恋人关系 | +5 | 无 | - |
| kiss | 亲亲 | 需要恋人关系 | +8 | 无 | - |
| hold_hands | 牵手 | 需要恋人关系 | +1 | 无 | - |
| wish | 许愿 | 5级(灵魂伴侣) | +1 | 无 | - |
| love_letter | 写情书 | 5级+恋人关系 | +1 | 无 | - |
响应字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
| emotion | string | AI当前情绪(happy/sad/angry/neutral/surprised/fearful/disgusted) |
| location | string | AI当前位置(classroom/campus/bedroom) |
| time_period | string | 当前时间段(day/afternoon/night) |
| added_points | int | 本次获得的亲密度点数 |
| current_intimacy | int | 当前总亲密度点数 |
| current_level | string | 当前等级名称 |
| level_changed | bool | 是否升级 |
| relationship_status | string | 关系状态(normal/lover) |
响应示例
json
{
"code": 0,
"message": "success",
"data": {
"action_id": "660e8400-e29b-41d4-a716-446655440000",
"action_type": "poke",
"action_name": "戳一下",
"ai_response": "*被你戳了一下,有点害羞* 哎呀,干嘛戳人家啦~ 不过...感觉还挺亲切的呢...",
"emotion": "happy",
"location": "classroom",
"time_period": "day",
"added_points": 1,
"current_intimacy": 201,
"current_level": "普通朋友",
"level_changed": false,
"relationship_status": "normal",
"created_at": "2025-10-03T12:35:00Z"
}
}错误情况
- 401: 未认证
- 400: 动作类型无效
- 403: 不满足动作执行条件(等级不够/非恋人)
- 422: 冷却时间未到
- 500: AI服务异常
示例代码
bash
curl -X POST http://localhost:8081/v1/actions/execute \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-d '{
"action_type": "poke"
}'javascript
const response = await fetch('http://localhost:8081/v1/actions/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify({
action_type: 'poke'
})
});
const data = await response.json();
console.log(data.data.ai_response);python
import requests
response = requests.post(
'http://localhost:8081/v1/actions/execute',
headers={
'Authorization': f'Bearer {access_token}'
},
json={
'action_type': 'poke'
}
)
data = response.json()
print(data['data']['ai_response'])