Fix discuss channel auto-forward deletion

Skip moderation for automatic forwards / channel sender messages in linked discussion groups.

Made-with: Cursor
This commit is contained in:
Artemii Peretiachenko 2026-04-10 17:51:24 +02:00
parent 89c472708b
commit 1aa6aa006c

View file

@ -252,6 +252,13 @@ async def anti_spam_all_messages(message: Message, bot: Bot, cfg: Config, db: Da
if not _is_allowed_chat(cfg, chat_id):
return
# Discussion groups can receive automatic forwards from a linked channel.
# These messages are not user spam and must never be deleted.
if getattr(message, "is_automatic_forward", False):
return
if message.sender_chat is not None and getattr(message.sender_chat, "type", None) == "channel":
return
user = message.from_user
if user is None or user.is_bot:
return