Skip to content

执行动作

接口说明

执行特定动作(如戳一下、抱抱等)。

请求信息

  • 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-

响应字段说明

字段类型说明
emotionstringAI当前情绪(happy/sad/angry/neutral/surprised/fearful/disgusted)
locationstringAI当前位置(classroom/campus/bedroom)
time_periodstring当前时间段(day/afternoon/night)
added_pointsint本次获得的亲密度点数
current_intimacyint当前总亲密度点数
current_levelstring当前等级名称
level_changedbool是否升级
relationship_statusstring关系状态(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'])

Released under the MIT License.