Refactoring: step3
- вся работа с shelve унесена в report - вся работа с БД унесена в моделс (крме команд админа) - ид книги лутца и звука вынесены в константы - исправлен баг в проверке на смешанный алфавит при определении спама, добавлены константы для более точного выявления - написаны новые тесты в том числе на цитаты и действия админов
This commit is contained in:
+3
-4
@@ -5,12 +5,11 @@ from telebot import types
|
||||
from .config import WHITEIDS
|
||||
from .constants import LOG_COMM, ALLOWED_WORDS, URL_RX
|
||||
from .helpers import is_spam, is_in_not_allowed, is_ban_words_in_caption
|
||||
from .models import Chat, session
|
||||
from .models import is_antispam_enabled
|
||||
|
||||
|
||||
def in_spam_list(message: types.Message) -> bool:
|
||||
"""Check for mentioning unwanted persons in text."""
|
||||
antispam_is_enabled = session.query(Chat.antispam).filter_by(chat_id=message.chat.id).first()[0]
|
||||
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 is_spam(message.text):
|
||||
@@ -30,7 +29,7 @@ def in_caption_spam_list(message: types.Message) -> bool:
|
||||
|
||||
def in_delete_list(message: types.Message) -> bool:
|
||||
"""Check for URLs in message and delete."""
|
||||
antispam_is_enabled = session.query(Chat.antispam).filter_by(chat_id=message.chat.id).first()[0]
|
||||
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 URL_RX.search(message.text) and is_in_not_allowed(ALLOWED_WORDS, message.text):
|
||||
|
||||
Reference in New Issue
Block a user