Добавлен транслит, спецсимволы и 2-ая проверка (замена символов на точку, вместо пустоты)

main
t 11 months ago
parent 9b0e56026f
commit ce6dfecd23

@ -41,6 +41,8 @@ bot = telebot.TeleBot(db['token'])
from re import search, match, sub, compile from re import search, match, sub, compile
def is_bad(word, bad, excepts): def is_bad(word, bad, excepts):
#Replace spec.symbols
# Excepts # Excepts
if word in excepts: if word in excepts:
return False return False
@ -53,14 +55,30 @@ def is_bad(word, bad, excepts):
else: else:
return False return False
### TRANSLIT an OTHER ######
def rep(word):
rep = [['e','е'], ['a','а'], ['i','и'], ['t','т'], ['y','у'], ['u','у'], ['o','о'], ['d','д'], ['x','х'], ['t','т'], ['p','п'],
['r','р'], ['h','х'], ['b','б'], ['n','н'],
['🇽','х'], ['🇾','у'], ['🇹','т'], ['🇪','е'],
['','х'], ['','х'], ['','х'] ]
for i in rep:
word = word.replace(i[0], i[1])
print(word)
return word
####### CATCH BAD WORDS #### ####### CATCH BAD WORDS ####
def catch(message): def catch(message):
bad_list = ['х.+й', 'xуи', 'xyи', 'х', 'xyй', 'xуй', 'ху.', '.+хуё', 'xyu', 'xui', 'х', 'хй', 'поху', bad_list = ['х.+й', 'xуи', 'xyи', 'х', 'xyй', 'xуй', 'ху.', '.+хуё', 'xyu', 'xui', 'х', 'поху', '.уй', 'ах.ен', 'а.уе',
'бл.+ть', 'бля', 'блят', 'бл.+ть', 'бля', 'бл.+т',
'бл+.дь', 'бл+.дь',
'трах', 'еб.+ть', 'ебу', 'ебал', '..ебен', 'ебан', 'ёбан', 'ебть', 'eby', '..ебись', 'уеб', 'уёб', 'ебей', 'трах', 'еб.+ть', 'ебу', 'ебал', '..ебен', 'ебан', 'ёбан', 'ебть', 'eby', '..ебись', 'уеб', 'уёб', 'ебей', 'ебу', 'ебл', 'еба',
'еб.+утые', 'е.+б.+утые', 'ебан', 'еб.+н', 'ебн', 'ёбн',
'пр..ба', '.б', 'у.б', '.блан',
'п.+зда', 'пиз.+ец', 'пизд', 'пизец', 'пздец', 'п.+здец', 'пизд', 'п.+зда', 'пиз.+ец', 'пизд', 'пизец', 'пздец', 'п.+здец', 'пизд',
'пид.+р', 'пидр', 'пид.+р', 'пидр',
'д.лб.+б', 'д.лб.+б',
@ -72,6 +90,8 @@ def catch(message):
bad_found = False bad_found = False
for check in words: for check in words:
# Mat -> Мат
check = rep(check)
# -М#ат$ => Мат # -М#ат$ => Мат
regex = compile('[^a-zA-Zа-яА-ЯЁё]') regex = compile('[^a-zA-Zа-яА-ЯЁё]')
check = regex.sub('', check) check = regex.sub('', check)
@ -79,9 +99,22 @@ def catch(message):
break break
for bad in bad_list: for bad in bad_list:
if is_bad(check.lower(), bad, excepts) == True: if is_bad(check.lower(), bad, excepts) == True:
print(bad) #print(bad)
bad_found = True bad_found = True
break break
if not bad_found:
for check in words:
check = rep(check)
regex = compile('[^a-zA-Zа-яА-ЯЁё]')
check = regex.sub('.', check)
if bad_found:
break
for bad in bad_list:
if is_bad(check.lower(), bad, excepts) == True:
#print(bad)
bad_found = True
break
if bad_found: if bad_found:
bot.delete_message(message.chat.id, message.id) bot.delete_message(message.chat.id, message.id)
@ -96,7 +129,7 @@ def catch_edited_messages(message):
catch(message) catch(message)
#''' '''
while True: while True:
try: try:
bot.polling() bot.polling()
@ -106,4 +139,4 @@ while True:
pass pass
''' '''
bot.polling() bot.polling()
''' #'''

Loading…
Cancel
Save