From 926e0df09555c4043f4c11bbb796d770f9cadb5d Mon Sep 17 00:00:00 2001 From: clown145 Date: Thu, 12 Feb 2026 01:56:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E4=B8=80test=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E5=B9=B6=E6=94=AF=E6=8C=81TG=E8=AF=9D?= =?UTF-8?q?=E9=A2=98=E7=88=B6=E7=BA=A7=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 8 +++++++- src/infrastructure/config/config_manager.py | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 15b10c4..c81abdf 100644 --- a/main.py +++ b/main.py @@ -919,7 +919,13 @@ class QQGroupDailyAnalysis(Star): yield event.plain_result("✅ 已重新加载配置并重启定时任务") elif action == "test": - if not self.config_manager.is_group_allowed(group_id): + check_target = getattr(event, "unified_msg_origin", None) + if not check_target: + check_target = ( + f"{self._get_platform_id_from_event(event)}:GroupMessage:{group_id}" + ) + + if not self.config_manager.is_group_allowed(check_target): yield event.plain_result("❌ 请先启用当前群的分析功能") return diff --git a/src/infrastructure/config/config_manager.py b/src/infrastructure/config/config_manager.py index 0608edd..c0da683 100644 --- a/src/infrastructure/config/config_manager.py +++ b/src/infrastructure/config/config_manager.py @@ -62,11 +62,19 @@ class ConfigManager: target = str(group_id_or_umo) target_simple_id = target.split(":")[-1] if ":" in target else target + target_parent_id = ( + target_simple_id.split("#", 1)[0] + if "#" in target_simple_id + else target_simple_id + ) def _is_match(item: str, target: str, target_simple_id: str) -> bool: if ":" in item: return item == target - return item == target_simple_id + if item == target_simple_id: + return True + # 允许 Telegram 话题会话通过父群 ID 命中简单群号白/黑名单 + return "#" in target_simple_id and item == target_parent_id is_in_list = any(_is_match(item, target, target_simple_id) for item in glist)