From 53ef3bbf4f5f45e7e2677ec973d67953b6d36f13 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 19 Feb 2024 19:04:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BF=AE=E6=94=B9cqht?= =?UTF-8?q?tp=E7=AB=AF=E5=8F=A3=E5=90=8E=E4=BB=8D=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/dashboard/helper.py | 8 ++++---- addons/dashboard/server.py | 4 ++-- cores/qqbot/core.py | 9 ++++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/addons/dashboard/helper.py b/addons/dashboard/helper.py index fce45c825..e28069c86 100644 --- a/addons/dashboard/helper.py +++ b/addons/dashboard/helper.py @@ -104,14 +104,14 @@ class DashBoardHelper(): ) qq_gocq_platform_group = DashBoardConfig( config_type="group", - name="GO-CQHTTP 平台配置", + name="OneBot协议平台配置", description="", body=[ DashBoardConfig( config_type="item", val_type="bool", - name="启用 GO-CQHTTP 平台", - description="gocq 是一个基于 HTTP 协议的 CQHTTP 协议的实现。详见 github.com/Mrs4s/go-cqhttp", + name="启用", + description="支持cq-http、shamrock等(目前仅支持QQ平台)", value=config['gocqbot']['enable'], path="gocqbot.enable", ), @@ -135,7 +135,7 @@ class DashBoardHelper(): config_type="item", val_type="int", name="WebSocket 服务器端口", - description="", + description="目前仅支持正向 WebSocket", value=config['gocq_websocket_port'], path="gocq_websocket_port", ), diff --git a/addons/dashboard/server.py b/addons/dashboard/server.py index 292ae46c5..1d71854a7 100644 --- a/addons/dashboard/server.py +++ b/addons/dashboard/server.py @@ -332,8 +332,8 @@ class AstrBotDashBoard(): "tag": "" }, { - "title": "QQ_GOCQ", - "desc": "go-cqhttp", + "title": "OneBot协议", + "desc": "支持cq-http、shamrock等(目前仅支持QQ平台)", "namespace": "internal_platform_qq_gocq", "tag": "" } diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 4dd2f57b2..144f512c6 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -254,13 +254,16 @@ def run_qqchan_bot(cfg: dict, global_object: GlobalObject): def run_gocq_bot(cfg: dict, _global_object: GlobalObject): from model.platform.qq_gocq import QQGOCQ - logger.log("正在检查本地GO-CQHTTP连接...端口5700, 6700", tag="QQ") noticed = False + host = cc.get("gocq_host", "127.0.0.1") + port = cc.get("gocq_websocket_port", 6700) + http_port = cc.get("gocq_http_port", 5700) + logger.log(f"正在检查连接...host: {host}, ws port: {port}, http port: {http_port}", tag="QQ") while True: - if not gu.port_checker(5700, cc.get("gocq_host", "127.0.0.1")) or not gu.port_checker(6700, cc.get("gocq_host", "127.0.0.1")): + if not gu.port_checker(port=port, host=host) or gu.port_checker(port=http_port, host=host): if not noticed: noticed = True - logger.log("与GO-CQHTTP通信失败, 请检查GO-CQHTTP是否启动并正确配置。程序会每隔 5s 自动重试。", gu.LEVEL_CRITICAL, tag="QQ") + logger.log(f"连接到{host}:{port}(或{http_port})失败。程序会每隔 5s 自动重试。", gu.LEVEL_CRITICAL, tag="QQ") time.sleep(5) else: logger.log("检查完毕,未发现问题。", tag="QQ")