{ "name": "WeChatAIChating", "description": "微信AI陪聊", "variables": { "turn": 1, "relationBg": "", "chatArea": "", "chatHistoryMessage": "", "currentChatMessage": "", "lastHistoryMessage": "", "lastChatMessage": "", "lastChatRole": "", "lastHistoryChatMessage": "", "lastHistoryChatRole": "", "aiReply": "", "aiCallBack": 0, "sendBtnPos": "", "wx_send_btn_center_pos": "", "newChatMessage": "" }, "execute": [ { "type": "schedule", "condition": { "interval": "1s", "repeat": 2 }, "interval": [ { "type": "echo", "inVars": [ "==第 {{turn}} 轮==" ] }, { "type": "set", "variable": "{turn}", "value": "{turn} + 1" }, { "type": "if", "condition": "{chatArea}==\"\"", "then": [ { "type": "fun", "method": "img-bounding-box-location", "inVars": [ "ScreenShot.jpg", "ChatArea.png" ], "outVars": [ "{chatArea}" ] }, { "type": "echo", "inVars": [ "坐标: {{chatArea}}" ] } ], "else": [] }, { "type": "fun", "method": "ocr-chat", "inVars": [ "(242,242,242)", "(114,220,106)", "{chatArea}" ], "outVars": [ "{currentChatMessage}" ] }, { "type": "echo", "inVars": [ "当前聊天内容:{{currentChatMessage}}" ] }, { "type": "fun", "method": "read-txt", "inVars": [ "history/chat-history.txt" ], "outVars": [ "{chatHistoryMessage}" ] }, { "type": "fun", "method": "read-txt", "inVars": [ "history/bg.txt" ], "outVars": [ "{relationBg}" ] }, { "type": "echo", "inVars": [ "背景内容:{{relationBg}}" ] }, { "type": "if", "condition": "{relationBg}==\"\"", "then": [ { "type": "if", "condition": "{chatHistoryMessage}==\"\"", "then": [ { "type": "fun", "method": "ai-generate", "inVars": [ "根据聊天记录:{{currentChatMessage}},推理出我与聊天好友的关系背景,用一句话描述出来" ], "outVars": [ "{relationBg}", "{aiCallBack}" ] } ], "else": [ { "type": "fun", "method": "ai-generate", "inVars": [ "根据聊天记录:{{chatHistoryMessage}},推理出我与聊天好友的关系背景,用一句话描述出来" ], "outVars": [ "{relationBg}", "{aiCallBack}" ] } ] }, { "type": "while", "condition": "1 == aiCallBack", "body": [] }, { "type": "set", "variable": "{aiCallBack}", "value": "0" }, { "type": "echo", "inVars": [ "==AI生成关系背景==:{{relationBg}}" ] }, { "type": "fun", "method": "save-txt", "inVars": [ "{relationBg}", "history/bg.txt" ], "outVars": [] } ], "else": [] }, { "type": "fun", "method": "read-last-message", "inVars": [ "{currentChatMessage}" ], "outVars": [ "{lastChatMessage}", "{lastChatRole}" ] }, { "type": "echo", "inVars": [ "当前最后一条消息:{{lastChatMessage}}({{lastChatRole}})" ] }, { "type": "fun", "method": "read-last-message", "inVars": [ "{chatHistoryMessage}" ], "outVars": [ "{lastHistoryChatMessage}", "{lastHistoryChatRole}" ] }, { "type": "echo", "inVars": [ "==历史最后一条消息:{{lastHistoryChatMessage}}({{lastHistoryChatRole}})==" ] }, { "type": "if", "condition": "{lastChatMessage} != {lastHistoryChatMessage}", "then": [ { "type": "echo", "inVars": [ "AI自动回复流程开始==" ] }, { "type": "if", "condition": "{lastChatRole} == \"friend\"", "then": [ { "type": "fun", "method": "ai-generate", "inVars": [ "根据我们背景关系描述:{{relationBg}},以及我们的聊天记录:{{lastChatMessage}},帮我做出适合回复,不要给建议,直接给一条你认为最好的回复信息,回复信息字数要符合微信聊天习惯" ], "outVars": [ "{aiReply}", "{aiCallBack}" ] }, { "type": "while", "condition": "1 == aiCallBack", "body": [] }, { "type": "set", "variable": "{aiCallBack}", "value": "0" }, { "type": "fun", "method": "adb-input", "inVars": [ "{aiReply}" ], "outVars": [] }, { "type": "if", "condition": "{wx_send_btn_center_pos} != \"\"", "then": [ { "type": "fun", "method": "img-center-point-location", "inVars": [ "微信聊天界面的发送按钮定位图.png" ], "outVars": [ "{sendBtnPos}" ] }, { "type": "fun", "method": "persist-save", "inVars": [ "wx_send_btn_center", "{sendBtnPos}" ], "outVars": [] } ], "else": [ { "type": "fun", "method": "persist-read", "inVars": [ "wx_send_btn_center" ], "outVars": [ "{sendBtnPos}" ] } ] }, { "type": "fun", "method": "adb-click", "inVars": [ "{sendBtnPos}" ], "outVars": [] } ], "else": [] }, { "type": "fun", "method": "smart-chat-append", "inVars": [ "{chatHistoryMessage}", "{currentChatMessage}" ], "outVars": [ "{newChatMessage}" ] }, { "type": "fun", "method": "save-txt", "inVars": [ "{newChatMessage}", "history/chat-history.txt" ], "outVars": [] } ], "else": [] } ] } ] }