🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 3.2.10 猫猫托管所 #### (1)功能说明 猫主人要出差30天,猫猫不知道该怎么办了。你的猫猫托管所就是他们的不二选择哦!作为育猫员,你需要在30天里细心照顾猫猫,给他喂食、陪他玩耍。通过与猫猫之间的互动,你与猫猫的亲密值会不断增加,达到一定程度就能获得更高的等级哦~ 30天后,猫主人会领走猫猫,到时候看看你获得的等级是什么吧! #### (2)接口说明 **请求方法** * POST **请求地址** * http://api.ruyi.ai/v2/message **请求参数说明** |参数名 |参数类型 | 是否必须 |参数说明 | :-----| :---| :---:|:----- |q |String| 是| 自然语言表达,例如“猫猫托管所”等 |app_key| String|是 |应用开发者秘钥,注册开发者后台账号,建立虚拟助理后获得 |user_id |String| 是 |用户唯一标识,便于支持个性化语义解析。建议开发者使用 UUID 字符,且不同用户必须用不同的 user_id,防止意图串。 #### (3)返回说明 **返回参数说明** |名称 |类型| 说明 |:---|:---|:--- |code |Integer | 返回代码 |msg | String |返回代码描述 |parameters|JSON Object |解析到的实体以及服务说明 |action|String|服务的接口名称 |name| String|匹配的意图名称 |result | JSON Object| 接口返回内容 |outputs| Array| 服务输出结果,微信端使用 type 类型为 wechat 开头的内容;硬件端收到所有内容,依据需求解析使用 **返回代码说明** |返回代码 |错误类型|说明 |:---|:---|:--- |0/200 |成功 |请求成功 |400 |无效请求 |某些必需参数缺失或参数值错误,详见msg字段 |401 |未授权 |授权失败,app_key缺失或错误 |403 |请求被禁止|有效请求,但服务拒绝响应,请联系contact@ruyi.ai |408 |请求超时 |请求响应超时,一般响应时间设置为2000ms以内 |429 |短时间内大量访问 |短时间内请求数过多 |500 |内部错误 |服务处理异常 |503 |服务不可用|服务异常或正在维护 #### (4)请求示例 **请求范例** 打开猫猫托管所 好 喂猫粮 退出 **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=游戏怎么玩 (游戏玩法介绍) 返回结果 ```json {"code": 0, "msg": "ok", "result"{    "_text": "游戏怎么玩",    "msg_id": "ce18e797-49f3-4af4-91de-077ff66e778b",    "intents": [        {            "parameters": {                "service": "cat"            },            "action": "猫猫情报",            "name": "游戏怎么玩",            "result": {                    "catCount": 1,                    "openGameTimes": 7,                    "name": "多尔衮",                    "intimacy": 525,                    "money": 0,                    "level": 3,                    "toNextLevelScore": 60,                    "startLevelUp": 0,                    "startDate": "Jan 15, 2019 4:47:32 PM",                    "lastInteractionDate": "Jan 17, 2019 11:49:06 AM",                    "interactionTimes": 5,                    "touchCatCount": 2,                    "autoDealDate": "Jan 17, 2019 11:47:44 AM",                    "degree": {                        "satiety": 80,                        "attention": 90,                        "happiness": 70                    },                    "raisingDays": 2                   "text": "游戏周期为30天。玩家通过喂食、陪伴等“互动行为”来维持猫猫的各项“指标程度”,从而增加与猫猫的“亲密值”。玩家的等级也就随之增加,不断地解锁新的互动玩法。多尔衮饱腹程度是80%,还在等吃的呢,跟我说喂猫粮",                    "type": "dialog"            },            "outputs": [                {                    "type": "wechat.text",                    "property": {                        "text": "游戏周期为30天。玩家通过喂食、陪伴等“互动行为”来维持猫猫的各项“指标程度”,从而增加与猫猫的“亲密值”。玩家的等级也就随之增加,不断地解锁新的互动玩法。多尔衮饱腹程度只有80%,跟我说喂猫粮"                    }                },                {                    "type": "dialog",                    "property": {                    "text": "游戏周期为30天。玩家通过喂食、陪伴等“互动行为”来维持猫猫的各项“指标程度”,从而增加与猫猫的“亲密值”。玩家的等级也就随之增加,不断地解锁新的互动玩法。多尔衮饱腹程度是80%,还在等吃的呢,跟我说喂猫粮",                        "emotion": "calm"                    }                }            ],            "score": "1.0",            "scoreColor": "c4",            "is_match": 1,            "skill_id": "0ce04a78-edb0-4398-bd84-64cc7af66d21",            "id": "e933dcdd-a56f-4139-81eb-a69a5dc65719"        }    ],    "meta_process_milliseconds": 198 } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=喂猫粮 (喂猫粮) 返回结果 ```json {"code": 0, "msg": "ok", "result" {    "_text": "喂猫粮",    "msg_id": "dd57bf4f-8308-41b7-b263-9877b1162861",    "intents": [        {            "parameters": {                "action": "satiety#20#3#feedfood",                "service": "cat"            },            "action": "猫猫互动",            "name": "互动",            "result": {                    "catCount": 1,                    "openGameTimes": 7,                    "name": "多尔衮",                    "intimacy": 525,                    "money": 0,                    "level": 3,                    "toNextLevelScore": 60,                    "startLevelUp": 0,                    "startDate": "Jan 15, 2019 4:47:32 PM",                    "lastInteractionDate": "Jan 17, 2019 11:48:45 AM",                    "interactionTimes": 5,                    "touchCatCount": 2,                    "autoDealDate": "Jan 17, 2019 11:47:44 AM",                    "degree": {                        "satiety": 80,                        "attention": 90,                        "happiness": 70                    },                    "raisingDays": 2                    "text": "http://image.ruyi.ai/chanshiguan/喂猫粮old.m4a",                     "type": "dialog"            },            "outputs": [                {                    "type": "wechat.text",                    "property": {                        "text": "http://image.ruyi.ai/chanshiguan/喂猫粮old.m4a"                    }                },                {                    "type": "voice",                    "property": {                        "name": null,                        "voice\_url": "http://image.ruyi.ai/chanshiguan/喂猫粮old.m4a"                    }                },                {                    "type": "dialog",                    "property": {                        "text": "多尔衮在大口吃猫粮!他的饱腹程度是80%,还在等吃的呢,跟我说喂牛奶",                        "emotion": "calm"                    }                }            ],            "score": "1.0",            "scoreColor": "c4",            "is_match": 1,            "skill_id": "0ce04a78-edb0-4398-bd84-64cc7af66d21",            "id": "a1e09b67-93bf-4a77-bde8-49d732d8cf17"        }    ],    "meta_process_milliseconds": 282 } ``` **请求示例退出** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=退出 (退出游戏并返回饱腹程度、被关注程度,开心度程度) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "退出", "msg_id": "15f146df-bc6e-48fe-b967-c78acdac2fe6", "intents": [ { "parameters": { "any": "", "退出": "结束", "any1": "", "service": "cat" }, "action": "猫猫情报", "name": "退出如意技能", "result": { "catCount": 1, "openGameTimes": 7, "name": "多尔衮", "intimacy": 525, "money": 0, "level": 3, "toNextLevelScore": 60, "startLevelUp": 0, "startDate": "Jan 15, 2019 4:47:32 PM", "lastInteractionDate": "Jan 17, 2019 11:49:16 AM", "interactionTimes": 5, "touchCatCount": 2, "autoDealDate": "Jan 17, 2019 11:47:44 AM", "degree": { "satiety": 80, "attention": 90, "happiness": 70 }, "raisingDays": 2 "text": "已退出猫猫托管所。多尔衮的饱腹程度为80%、被关注程度为90%,开心度程度为70%,注意哦!指标未满。待会有空求回来照顾多尔衮。", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "已退出猫猫托管所。想照顾猫猫的时候记得来找我,猫猫在这等着你哦" } }, { "type": "voice", "property": { "name": "room_door_C.mp3", "voice_url": "https://qiniu.ruyi.ai/FvL1ssum7VALYxGsd02Yk6WYKRhx/room_door_C.mp3" } }, { "type": "dialog", "property": { "text": "已退出猫猫托管所。多尔衮的饱腹程度为80%、被关注程度为90%,开心度程度为70%,注意哦!指标未满。待会有空求回来照顾多尔衮。", "emotion": "calm" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "0ce04a78-edb0-4398-bd84-64cc7af66d21", "id": "5d0819ca-7a70-46ab-800b-6c78644b295a" } ], "meta_process_milliseconds": 124 } ``` **详细参数说明** |名称|类型|说明| |:---|:---|:--- |service | String |服务名称 |action|String|互动的词典参数,格式 degree#changeValue#needLevel#behavour |catCount | int | 猫猫数量 |openGameTimes | int |打开游戏次数 |name|String|猫猫名字 |intimacy | int |亲密度 |money|int|金钱数(本期暂未支持) |level | int |猫猫等级 |startLevelUp|int|1:代表猫猫等级有提升。默认0 |startDate| String |开始时间 |lastInteractionDate|String|最近一次交互时间 |interactionTimes | int |交互次数 |touchCatCount|int|摸猫次数 |degree | String |相关指标参数 |degree.satiety | int |饱腹度 |degree.attention|int|被关注度 |degree.happiness | int |开心程度 |raisingDays | int |养猫天数 **指令清单** |指令名称|范例| |:---|:--- |唤醒 | 打开猫猫托管所 |游戏玩法介绍 | 游戏怎么玩 |互动动作 | 喂猫粮 |退出 | 退出