fix: follow-up for salvaged PR #22263

- Restore allowed_chats gate before thread_id check so ignored_threads
  applies universally (even to guest mentions).
- Compute _message_mentions_bot once in _should_process_message to
  eliminate redundant second entity scan when guest_mode=true and the
  message does not mention the bot.
- Remove redundant _is_group_chat from _is_guest_mention (caller already
  verified the message is a group chat).
- Update _telegram_allowed_chats docstring to note guest_mode exception.
- Add test coverage: bot_command entity, text_mention entity,
  caption_entities, and ignored_threads + guest_mode interaction.
- Add nik1t7n to AUTHOR_MAP.
This commit is contained in:
kshitijk4poor 2026-05-10 00:19:19 +05:30 committed by kshitij
parent 55f518e521
commit dae94fa652
4 changed files with 71 additions and 9 deletions

View file

@ -186,6 +186,23 @@ def test_guest_mode_defaults_to_false_for_allowed_chat_bypass():
assert adapter._should_process_message(mentioned) is False
def test_guest_mode_mention_dropped_in_ignored_thread():
"""A guest mention in an ignored thread is still dropped — thread gate runs first."""
adapter = _make_adapter(
require_mention=True,
allowed_chats=["-200"],
guest_mode=True,
ignored_threads=[42],
)
mentioned = _group_message(
"hi @hermes_bot",
chat_id=-201,
entities=[_mention_entity("hi @hermes_bot")],
thread_id=42,
)
assert adapter._should_process_message(mentioned) is False
def test_ignored_threads_drop_group_messages_before_other_gates():
adapter = _make_adapter(require_mention=False, free_response_chats=["-200"], ignored_threads=[31, "42"])