|
|
@@ -150,13 +150,20 @@ def _mention_text(msg) -> str:
|
|
|
def _is_bot_mentioned(msg) -> bool:
|
|
|
"""判断消息是否 @了机器人。
|
|
|
|
|
|
- EventMessage.mentions 是 List[MentionEvent],其中 mentioned_type='app'
|
|
|
- 表示 @了应用(机器人)。群聊里只有 @机器人 的消息才需要响应。
|
|
|
+ 飞书机器人消息的 mentions 字段:
|
|
|
+ - mentioned_type == 'bot' 表示 @了机器人(不是 'app')
|
|
|
+ - key == '@_user_1' 是机器人的特殊标识
|
|
|
"""
|
|
|
if not (msg and msg.mentions):
|
|
|
return False
|
|
|
+
|
|
|
for mt in msg.mentions:
|
|
|
- if getattr(mt, "mentioned_type", "") == "app":
|
|
|
+ mtype = getattr(mt, "mentioned_type", "")
|
|
|
+ mkey = getattr(mt, "key", "")
|
|
|
+ # 飞书 bot 的 @mention 类型是 'bot',key 是 '@_user_1'
|
|
|
+ if mtype == "bot":
|
|
|
+ return True
|
|
|
+ if mkey == "@_user_1":
|
|
|
return True
|
|
|
return False # 只要 mention 了,就看作对该 bot 的指令入口(群内一般是 @机器人)
|
|
|
|
|
|
@@ -166,9 +173,9 @@ def _handle_data_command(message_id: str, feishu: FeishuChat):
|
|
|
_log("[指令] 看数据 → 开始采集")
|
|
|
publisher = None
|
|
|
try:
|
|
|
- # 复用 xhs_daily_report 的采集逻辑
|
|
|
+ # XiaohongshuPublisher 在 cdp_publish 模块(sys.path 已注入)
|
|
|
+ from cdp_publish import XiaohongshuPublisher
|
|
|
from xhs_daily_report import (
|
|
|
- XiaohongshuPublisher,
|
|
|
collect_overview,
|
|
|
collect_notes,
|
|
|
screenshot_current,
|