fix: fall back to heuristic when bot open_id fetch fails

If _fetch_bot_open_id returns None the exact-match path would silently
disable all @mention detection. Restore the old heuristic as a fallback.
Add 6 unit tests for _is_bot_mentioned covering both paths.

Made-with: Cursor
This commit is contained in:
Xubin Ren
2026-04-06 13:49:38 +08:00
committed by Xubin Ren
parent 1b368a33dc
commit c88d97c652
2 changed files with 69 additions and 2 deletions
+7 -2
View File
@@ -431,8 +431,13 @@ class FeishuChannel(BaseChannel):
if not mid:
continue
mention_open_id = getattr(mid, "open_id", None) or ""
if self._bot_open_id and mention_open_id == self._bot_open_id:
return True
if self._bot_open_id:
if mention_open_id == self._bot_open_id:
return True
else:
# Fallback heuristic when bot open_id is unavailable
if not getattr(mid, "user_id", None) and mention_open_id.startswith("ou_"):
return True
return False
def _is_group_message_for_bot(self, message: Any) -> bool: