From f1979fc030726cbab12c05ac33d459a1d1ba331c Mon Sep 17 00:00:00 2001 From: Rykov7 Date: Wed, 24 Jul 2024 11:20:23 +0300 Subject: [PATCH] BAN_WORDS deprecated --- src/constants.py | 1 - src/helpers.py | 4 ++-- tests/test_helpers.py | 6 +----- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/constants.py b/src/constants.py index 2189ff2..96f5162 100644 --- a/src/constants.py +++ b/src/constants.py @@ -51,7 +51,6 @@ LIB = types.InlineKeyboardButton("📚 Книги", url="https://telegra.ph/what NON_GRATA = {"дудар", "хауди", "dudar"} -BAN_WORDS = {"GREEN", "TONCOIN", "казино", "🍋", "Выплаты", "🎰"} ZEN = [ "Beautiful is better than ugly.", diff --git a/src/helpers.py b/src/helpers.py index c9901ac..53e0c79 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -6,7 +6,7 @@ from urllib.request import urlopen from telebot import types from .constants import ( - NON_GRATA, ADMIN_ID, ONLY_RUS_LETTERS, ONLY_ENG_LETTERS, RULES_TEXT, SYMBOLS, BAN_WORDS + NON_GRATA, ADMIN_ID, ONLY_RUS_LETTERS, ONLY_ENG_LETTERS, RULES_TEXT, SYMBOLS ) from .models import session, BadWord @@ -73,7 +73,7 @@ def is_in_not_allowed(word_list: list, msg: str) -> bool: def is_ban_words_in_caption(caption: str) -> bool: - return any(ban_word in caption for ban_word in BAN_WORDS) + return is_spam(caption) def is_nongrata(type_message: types.Message) -> bool: diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 12c5274..77b8bf2 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1,6 +1,6 @@ from unittest import TestCase, main from unittest.mock import MagicMock -from src.constants import BAN_WORDS, ADMIN_ID, RULES_TEXT +from src.constants import ADMIN_ID, RULES_TEXT from src.helpers import ( is_spam, is_mixed, is_ban_words_in_caption, is_in_not_allowed, is_nongrata, is_admin, fetch_rule, cleaned_text, remove_spaces, has_no_letters, has_links @@ -100,10 +100,6 @@ class TestSpam(TestCase): class TestOthers(TestCase): - def test_ban(self): - for word in BAN_WORDS: - with self.subTest(f"check ban word({word})"): - self.assertTrue(is_ban_words_in_caption(word)) def test_allowed(self): params = (