From 9b0e56026faca2ae4696d69d424d337bc8e5eb46 Mon Sep 17 00:00:00 2001 From: t Date: Thu, 9 Nov 2023 23:15:22 +0300 Subject: [PATCH] =?UTF-8?q?+=D0=92=D0=BE=D1=81=D0=BF=D1=80=D0=B8=D0=B8?= =?UTF-8?q?=D0=BC=D1=87=D0=B8=D0=B2=D0=BE=D1=81=D1=82=D1=8C=20=D0=BA=20?= =?UTF-8?q?=D0=B1=D1=83=D0=BA=D0=B2=D0=B5=20=D1=91,=20=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BB=D1=91=D0=BD=D0=BD=D1=8B=D0=B9=20=D1=81=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=80=D1=8C,=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- antimat.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/antimat.py b/antimat.py index 31642da..a72eb2f 100644 --- a/antimat.py +++ b/antimat.py @@ -40,14 +40,13 @@ bot = telebot.TeleBot(db['token']) ########## ALANYS WORD ##### from re import search, match, sub, compile -def is_bad(word, bad): +def is_bad(word, bad, excepts): + # Excepts + if word in excepts: + return False + # Agressive mode, causes false positives #res = search(bad, word) - - # -М#ат$ => Мат - regex = compile('[^a-zA-Zа-яА-Я]') - word = regex.sub('', word) - res = match(bad, word) if res is not None: return True @@ -64,16 +63,22 @@ def catch(message): 'трах', 'еб.+ть', 'ебу', 'ебал', '..ебен', 'ебан', 'ёбан', 'ебть', 'eby', '..ебись', 'уеб', 'уёб', 'ебей', 'п.+зда', 'пиз.+ец', 'пизд', 'пизец', 'пздец', 'п.+здец', 'пизд', 'пид.+р', 'пидр', + 'д.лб.+б', 'f.+ck', 's.+ck', 'fck', 'sck'] + excepts = ['хороший'] + words = message.text.split() bad_found = False for check in words: + # -М#ат$ => Мат + regex = compile('[^a-zA-Zа-яА-ЯЁё]') + check = regex.sub('', check) if bad_found: break for bad in bad_list: - if is_bad(check.lower(), bad) == True: + if is_bad(check.lower(), bad, excepts) == True: print(bad) bad_found = True break