From 8fa3da9ca548fad0165d27aae03e87fd7f1e1a68 Mon Sep 17 00:00:00 2001 From: JS00000 Date: Wed, 12 Apr 2023 05:41:48 +0800 Subject: [PATCH] wechatmp: voice input support --- channel/wechatmp/README.md | 2 +- channel/wechatmp/ServiceAccount.py | 2 +- channel/wechatmp/SubscribeAccount.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/channel/wechatmp/README.md b/channel/wechatmp/README.md index 5fb2eda..225facc 100644 --- a/channel/wechatmp/README.md +++ b/channel/wechatmp/README.md @@ -46,7 +46,7 @@ sudo iptables-save > /etc/iptables/rules.v4 公共api有访问频率限制(免费账号每分钟最多20次ChatGPT的API调用),这在服务多人的时候会遇到问题。因此这里多加了一个设置私有api_key的功能。目前通过godcmd插件的命令来设置私有api_key。 ## 测试范围 -目前在`RoboStyle`这个公众号上进行了测试(基于[wechatmp-stable分支](https://github.com/JS00000/chatgpt-on-wechat/tree/wechatmp-stable),而[master分支](https://github.com/zhayujie/chatgpt-on-wechat)含有最新功能,但是稳定性有待测试),感兴趣的可以关注并体验。开启了godcmd, Banwords, role, dungeon, finish这五个插件,其他的插件还没有测试。百度的接口暂未测试。语音对话没有测试。图片直接以链接形式回复(没有临时素材上传接口的权限)。 +目前在`RoboStyle`这个公众号上进行了测试(基于[wechatmp分支](https://github.com/JS00000/chatgpt-on-wechat/tree/wechatmp)),感兴趣的可以关注并体验。开启了godcmd, Banwords, role, dungeon, finish这五个插件,其他的插件还没有测试。百度的接口暂未测试。语音对话没有测试。图片直接以链接形式回复(没有临时素材上传接口的权限)。 ## TODO * 服务号交互完善 diff --git a/channel/wechatmp/ServiceAccount.py b/channel/wechatmp/ServiceAccount.py index ae535ea..eeef66d 100644 --- a/channel/wechatmp/ServiceAccount.py +++ b/channel/wechatmp/ServiceAccount.py @@ -21,7 +21,7 @@ class Query(): webData = web.data() # logger.debug("[wechatmp] Receive request:\n" + webData.decode("utf-8")) wechatmp_msg = receive.parse_xml(webData) - if wechatmp_msg.msg_type == 'text': + if wechatmp_msg.msg_type == 'text' or wechatmp_msg.msg_type == 'voice': from_user = wechatmp_msg.from_user_id message = wechatmp_msg.content.decode("utf-8") message_id = wechatmp_msg.msg_id diff --git a/channel/wechatmp/SubscribeAccount.py b/channel/wechatmp/SubscribeAccount.py index b1047c3..7de2abd 100644 --- a/channel/wechatmp/SubscribeAccount.py +++ b/channel/wechatmp/SubscribeAccount.py @@ -22,7 +22,7 @@ class Query(): webData = web.data() logger.debug("[wechatmp] Receive request:\n" + webData.decode("utf-8")) wechatmp_msg = receive.parse_xml(webData) - if wechatmp_msg.msg_type == 'text': + if wechatmp_msg.msg_type == 'text' or wechatmp_msg.msg_type == 'voice': from_user = wechatmp_msg.from_user_id to_user = wechatmp_msg.to_user_id message = wechatmp_msg.content.decode("utf-8")