From e2f1362a1fcdafda5a95c1e7e78e42042942fa7c Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Tue, 9 Jan 2024 22:25:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dmyid=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E5=9C=A8gocq=E5=B9=B3=E5=8F=B0=E4=B8=8A=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 6 +++--- model/command/command.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 797944754..3cc161721 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -347,16 +347,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 - gu.log("正在检查本地GO-CQHTTP连接...端口5700, 6700", tag="QQ") + gu.log("正在检查与 go-cqhttp 的连接...端口5700, 6700", tag="QQ") noticed = False 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 noticed: noticed = True - gu.log("与GO-CQHTTP通信失败, 请检查GO-CQHTTP是否启动并正确配置。程序会每隔 5s 自动重试。", gu.LEVEL_CRITICAL, tag="QQ") + gu.log("与 go-cqhttp 通信失败, 请检查 go-cqhttp 是否启动并正确配置。程序会每隔 5s 自动重试。", gu.LEVEL_CRITICAL, tag="QQ") time.sleep(5) else: - gu.log("检查完毕,未发现问题。", tag="QQ") + gu.log("成功连接到 go-cqhttp。", tag="QQ") break try: qq_gocq = QQGOCQ(cfg=cfg, message_handler=oper_msg) diff --git a/model/command/command.py b/model/command/command.py index 3a1abd1a6..2100206e5 100644 --- a/model/command/command.py +++ b/model/command/command.py @@ -82,7 +82,7 @@ class Command: if self.command_start_with(message, "plugin"): return True, self.plugin_oper(message, role, cached_plugins, platform) if self.command_start_with(message, "myid") or self.command_start_with(message, "!myid"): - return True, self.get_my_id(message_obj) + return True, self.get_my_id(message_obj, platform) if self.command_start_with(message, "nconf") or self.command_start_with(message, "newconf"): return True, self.get_new_conf(message, role) if self.command_start_with(message, "web"): # 网页搜索 @@ -105,8 +105,14 @@ class Command: return True, "已关闭网页搜索", "web" return True, f"网页搜索功能当前状态: {self.global_object.web_search}", "web" - def get_my_id(self, message_obj): - return True, f"你的ID:{str(message_obj.sender.tiny_id)}", "plugin" + def get_my_id(self, message_obj, platform): + user_id = "Unknown" + if platform == PLATFORM_QQCHAN: + user_id = str(message_obj.sender.tiny_id) + elif platform == PLATFORM_GOCQ: + user_id = str(message_obj.user_id) + + return True, f"你的ID:{user_id}", "plugin" def get_new_conf(self, message, role): if role != "admin":