diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index cffcef3b3..664a11307 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -140,6 +140,7 @@ CONFIG_METADATA_2 = { "enable": False, "ws_reverse_host": "0.0.0.0", "ws_reverse_port": 6199, + "ws_reverse_token": "", }, "gewechat(微信)": { "id": "gwchat", @@ -188,7 +189,7 @@ CONFIG_METADATA_2 = { "telegram_file_base_url": "https://api.telegram.org/file/bot", "telegram_command_register": True, "telegram_command_auto_refresh": True, - "telegram_command_register_interval": 300 + "telegram_command_register_interval": 300, }, }, "items": { @@ -258,6 +259,11 @@ CONFIG_METADATA_2 = { "type": "int", "hint": "aiocqhttp 适配器的反向 Websocket 端口。", }, + "ws_reverse_token": { + "description": "反向 Websocket Token", + "type": "string", + "hint": "aiocqhttp 适配器的反向 Websocket Token。未设置则不启用 Token 验证。", + }, "lark_bot_name": { "description": "飞书机器人的名字", "type": "string", diff --git a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py index fb152484e..9cf6b5bab 100644 --- a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py +++ b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py @@ -46,7 +46,10 @@ class AiocqhttpAdapter(Platform): ) self.bot = CQHttp( - use_ws_reverse=True, import_name="aiocqhttp", api_timeout_sec=180 + use_ws_reverse=True, + import_name="aiocqhttp", + api_timeout_sec=180, + access_token=platform_config["ws_reverse_token"], ) @self.bot.on_request()