Skip to content

Commit 654112c

Browse files
authored
feat(wecomai): implement long connection mode and update configuration options (#5930)
1 parent 5dd30f9 commit 654112c

6 files changed

Lines changed: 635 additions & 53 deletions

File tree

astrbot/core/config/default.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,20 @@ class ChatProviderTemplate(TypedDict):
342342
"企业微信智能机器人": {
343343
"id": "wecom_ai_bot",
344344
"type": "wecom_ai_bot",
345+
"hint": "如果发现字段有异常,请重新创建",
345346
"enable": True,
346-
"wecom_ai_bot_connection_mode": "webhook",
347+
"wecom_ai_bot_connection_mode": "long_connection", # long_connection, webhook
348+
"wecom_ai_bot_name": "",
349+
"wecomaibot_ws_bot_id": "",
350+
"wecomaibot_ws_secret": "",
351+
"wecomaibot_token": "",
352+
"wecomaibot_encoding_aes_key": "",
347353
"wecomaibot_init_respond_text": "",
348354
"wecomaibot_friend_message_welcome_text": "",
349-
"wecom_ai_bot_name": "",
350355
"msg_push_webhook_url": "",
351356
"only_use_webhook_url_to_send": False,
352-
"long_connection_bot_id": "",
353-
"long_connection_secret": "",
354-
"long_connection_ws_url": "wss://openws.work.weixin.qq.com",
355-
"long_connection_heartbeat_interval": 30,
356-
"token": "",
357-
"encoding_aes_key": "",
357+
"wecomaibot_ws_url": "wss://openws.work.weixin.qq.com",
358+
"wecomaibot_heartbeat_interval": 30,
358359
"unified_webhook_mode": True,
359360
"webhook_uuid": "",
360361
"callback_server_host": "0.0.0.0",
@@ -754,6 +755,22 @@ class ChatProviderTemplate(TypedDict):
754755
"type": "string",
755756
"hint": "当用户当天进入智能机器人单聊会话,回复欢迎语,留空则不回复。",
756757
},
758+
"wecomaibot_token": {
759+
"description": "企业微信智能机器人 Token",
760+
"type": "string",
761+
"hint": "用于 Webhook 回调模式的身份验证。",
762+
"condition": {
763+
"wecom_ai_bot_connection_mode": "webhook",
764+
},
765+
},
766+
"wecomaibot_encoding_aes_key": {
767+
"description": "企业微信智能机器人 EncodingAESKey",
768+
"type": "string",
769+
"hint": "用于 Webhook 回调模式的消息加密解密。",
770+
"condition": {
771+
"wecom_ai_bot_connection_mode": "webhook",
772+
},
773+
},
757774
"msg_push_webhook_url": {
758775
"description": "企业微信消息推送 Webhook URL",
759776
"type": "string",
@@ -764,33 +781,35 @@ class ChatProviderTemplate(TypedDict):
764781
"type": "bool",
765782
"hint": "启用后,企业微信智能机器人的所有回复都改为通过消息推送 Webhook 发送。消息推送 Webhook 支持更多的消息类型(如图片、文件等)。",
766783
},
767-
"long_connection_bot_id": {
784+
"wecomaibot_ws_bot_id": {
768785
"description": "长连接 BotID",
769786
"type": "string",
770787
"hint": "企业微信智能机器人长连接模式凭证 BotID。",
771788
"condition": {
772789
"wecom_ai_bot_connection_mode": "long_connection",
773790
},
774791
},
775-
"long_connection_secret": {
792+
"wecomaibot_ws_secret": {
776793
"description": "长连接 Secret",
777794
"type": "string",
778795
"hint": "企业微信智能机器人长连接模式凭证 Secret。",
779796
"condition": {
780797
"wecom_ai_bot_connection_mode": "long_connection",
781798
},
782799
},
783-
"long_connection_ws_url": {
800+
"wecomaibot_ws_url": {
784801
"description": "长连接 WebSocket 地址",
785802
"type": "string",
803+
"invisible": True,
786804
"hint": "默认值为 wss://openws.work.weixin.qq.com,一般无需修改。",
787805
"condition": {
788806
"wecom_ai_bot_connection_mode": "long_connection",
789807
},
790808
},
791-
"long_connection_heartbeat_interval": {
809+
"wecomaibot_heartbeat_interval": {
792810
"description": "长连接心跳间隔",
793811
"type": "int",
812+
"invisible": True,
794813
"hint": "长连接模式心跳间隔(秒),建议 30 秒。",
795814
"condition": {
796815
"wecom_ai_bot_connection_mode": "long_connection",
@@ -840,7 +859,7 @@ class ChatProviderTemplate(TypedDict):
840859
"unified_webhook_mode": {
841860
"description": "统一 Webhook 模式",
842861
"type": "bool",
843-
"hint": "启用后,将使用 AstrBot 统一 Webhook 入口,无需单独开启端口。回调地址为 /api/platform/webhook/{webhook_uuid}。",
862+
"hint": "Webhook 模式下使用 AstrBot 统一 Webhook 入口,无需单独开启端口。回调地址为 /api/platform/webhook/{webhook_uuid}。",
844863
},
845864
"webhook_uuid": {
846865
"invisible": True,

0 commit comments

Comments
 (0)