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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user