add ban for forwarding posts. fix

This commit is contained in:
Rykov7
2024-10-07 14:58:34 +03:00
parent 21738e0a22
commit 62d3603f14
+8 -4
View File
@@ -13,18 +13,22 @@ def in_spam_list(message: types.Message) -> bool:
from_user_id, title, from_user_name = message.from_user.id, message.chat.title, message.from_user.first_name from_user_id, title, from_user_name = message.from_user.id, message.chat.title, message.from_user.first_name
if from_user_id not in WHITEIDS and antispam_is_enabled: if from_user_id not in WHITEIDS and antispam_is_enabled:
if is_spam(message.text): if is_spam(message.text):
logging.info("!BAN!" + LOG_COMM % (title, from_user_id, from_user_name, message.text)) logging.info("[BAN]" + LOG_COMM % (title, from_user_id, from_user_name, message.text))
return True
if message.forward_from: # Запрет репостов из других групп.
return True return True
return False return False
def in_caption_spam_list(message: types.Message) -> bool: def in_caption_spam_list(message: types.Message) -> bool:
"""Check for mentioning unwanted words in caption.""" """Check for mentioning unwanted words in caption."""
antispam_is_enabled = is_antispam_enabled(message.chat.id)
from_user_id, title, from_user_name = message.from_user.id, message.chat.title, message.from_user.first_name
if from_user_id not in WHITEIDS and antispam_is_enabled:
if message.caption and is_ban_words_in_caption(message.caption): if message.caption and is_ban_words_in_caption(message.caption):
from_user_id, title, from_user_name = message.from_user.id, message.chat.title, message.from_user.first_name from_user_id, title, from_user_name = message.from_user.id, message.chat.title, message.from_user.first_name
logging.info("!BAN CAPTION!" + LOG_COMM % (title, from_user_id, from_user_name, message.caption)) logging.info("[BAN CAPTION]" + LOG_COMM % (title, from_user_id, from_user_name, message.caption))
return True
if message.forward_from: # Запрет репостов для Медиа.
logging.info("[BAN REPOST]" + LOG_COMM % (title, from_user_id, from_user_name))
return True return True
return False return False