mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 13:38:43 +00:00
feat(TraceID): 主要通过引入全链路追踪,增强了日志的可观测性,并加固了去重拦截逻辑
This commit is contained in:
@@ -613,8 +613,10 @@ class OneBotAdapter(PlatformAdapter):
|
||||
user_id = str(
|
||||
msg.get("user_id", msg.get("sender", {}).get("user_id", ""))
|
||||
)
|
||||
if user_id != self_id:
|
||||
continue
|
||||
if user_id not in self.bot_self_ids:
|
||||
# 如果内存中没有,尝试最后一次实时提取作为兜底
|
||||
if not self_id or user_id != self_id:
|
||||
continue
|
||||
|
||||
# 检查消息内容是否包含图片
|
||||
raw_message = msg.get("message", [])
|
||||
@@ -627,14 +629,18 @@ class OneBotAdapter(PlatformAdapter):
|
||||
if search_token:
|
||||
# 精确匹配 TraceID
|
||||
if search_token in msg_str:
|
||||
logger.debug(
|
||||
f"自检发现群 {group_id} 已有匹配 ID ({search_token}) 的图片回显,拦截重复发送。"
|
||||
logger.info(
|
||||
f"[OneBot] [真相检查] 发现匹配 ID ({search_token}) 的历史图片。拦截重复发送。群: {group_id}"
|
||||
)
|
||||
return True
|
||||
else:
|
||||
logger.debug(
|
||||
f"[OneBot] [真相检查] 发现机器人发送的图片,但 ID 不匹配。跳过。群: {group_id}"
|
||||
)
|
||||
else:
|
||||
# 广义匹配(回退模式)
|
||||
logger.debug(
|
||||
f"自检发现群 {group_id} 已有成功发送的图片回显,无需重试。"
|
||||
logger.info(
|
||||
f"[OneBot] [真相检查] 发现近期发送过的图片回显 (广义匹配)。无需重试。群: {group_id}"
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
@@ -87,6 +87,11 @@ class BotManager:
|
||||
elif bot_self_ids:
|
||||
self._bot_self_ids = [str(bot_self_ids)]
|
||||
|
||||
# 同步更新所有现有适配器的 ID 列表
|
||||
for adapter in self._adapters.values():
|
||||
if hasattr(adapter, "bot_self_ids"):
|
||||
adapter.bot_self_ids = self._bot_self_ids.copy()
|
||||
|
||||
def get_bot_instance(self, platform_id=None):
|
||||
"""获取指定平台的bot实例,如果不指定则返回第一个可用的实例"""
|
||||
if platform_id:
|
||||
|
||||
Reference in New Issue
Block a user