FEATURE 14: autoreaction

- если фулл_нейм пустой то будет сообщение о нарушении правила, само сообщение юзера будет удалено
- добавлена правка по спаму
- немного рефакторинга
- если сообщение содержит только слово из констант привет(полное совпадение) то выдаем правило непривет
This commit is contained in:
kotolex
2023-12-26 16:58:27 +05:00
parent 77e34681ec
commit 92bb50dd49
7 changed files with 99 additions and 39 deletions
+10 -3
View File
@@ -30,9 +30,8 @@ def is_mixed(text: str) -> bool:
Разбивает текст на слова и проверяет на смешанный алфавит, спамеры используют его. Слово допускается только
полностью на русском или русский + знаки пунктуации
"""
cleaned_text = ''.join(letter if letter not in SYMBOLS else ' ' for letter in text)
for word in cleaned_text.split():
word = word.strip().lower()
for word in cleaned_text(text).split():
word = word.strip()
if not word:
continue
if any(e in ONLY_RUS_LETTERS for e in word) and any(e in ONLY_ENG_LETTERS for e in word):
@@ -40,6 +39,14 @@ def is_mixed(text: str) -> bool:
return False
def cleaned_text(text: str) -> str:
return ''.join(letter.lower() if letter not in SYMBOLS else ' ' for letter in text)
def remove_spaces(text: str) -> str:
return ' '.join(word.strip() for word in text.split() if word.strip())
def is_in_not_allowed(word_list: list, msg: str) -> bool:
for word in word_list:
if word in msg.casefold():