From fdf55221e6c25fbf5127841c0f863fcfb222349c Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Mon, 28 Apr 2025 22:14:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0aiocqhttp=E5=AF=B9Tok?= =?UTF-8?q?en=E8=AE=BE=E7=BD=AE=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/config/default.py | 8 +++++++- .../sources/aiocqhttp/aiocqhttp_platform_adapter.py | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) 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()