mirror of
https://github.com/EDeev/chatping_abobot.git
synced 2026-10-07 20:49:45 +03:00
Переводы строк приведены к LF, удалено чужое голосовое из data/voices
1_7047.oga — голосовое сообщение участника чата, оставшееся от отладки распознавания.
This commit is contained in:
parent
ef4af56486
commit
4cd8470087
4 changed files with 200 additions and 195 deletions
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
* text=auto eol=lf
|
||||
*.jpg binary
|
||||
*.ogg binary
|
||||
*.oga binary
|
||||
*.db binary
|
||||
52
code/base.py
52
code/base.py
|
|
@ -1,26 +1,26 @@
|
|||
# ДАННЫЕ БОТА
|
||||
TOKEN = "XXXXXXXXXX" # @chat_abobot
|
||||
DEBAG = "XXXXXXXXXX" # Технический чат
|
||||
|
||||
TEX_GROUP = "XXXXXXXXXX"
|
||||
|
||||
# ОБРАЩЕНИЯ К ПОЛЬЗОВАТЕЛЯМ
|
||||
KILL_LIST = ["побить", "отмудохать", "избить", "уебать", "отметелить"]
|
||||
TMOK_LIST = ["поцеловать", "чмокнуть", "соснуть", "лайкнуть"]
|
||||
QUAT_LIST = [['дай', 'дайте'], ['ахуенный', 'ахуеный', 'охуеный', 'охуенный', 'блять', 'сука'], ['совет', 'совета']]
|
||||
|
||||
# ФРАЗЫ ИВЕНТ ДРАКИ
|
||||
VAR_WIN = ["опустив его ниже плинтуса!", "поставив его на место!"]
|
||||
VAR_LOSE = ["Кунг - Фу!", "магии!", "резинового члена!", "банды цапель!"]
|
||||
|
||||
# ПЕРЕВОДЧИК СЛОВ
|
||||
ERR = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||
"'", 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', '`']
|
||||
ERR_ = ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
|
||||
'"', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', '~']
|
||||
TRU = ['й', 'ц', 'у', 'к', 'е', 'н', 'г', 'ш', 'щ', 'з', 'х', 'ъ', 'ф', 'ы', 'в', 'а', 'п', 'р', 'о', 'л', 'д', 'ж',
|
||||
'э', 'я', 'ч', 'с', 'м', 'и', 'т', 'ь', 'б', 'ю', '.']
|
||||
TRU_ = ['Й', 'Ц', 'У', 'К', 'Е', 'Н', 'Г', 'Ш', 'Щ', 'З', 'Х', 'Ъ', 'Ф', 'Ы', 'В', 'А', 'П', 'Р', 'О', 'Л', 'Д', 'Ж',
|
||||
'Э', 'Я', 'Ч', 'С', 'М', 'И', 'Т', 'Ь', 'Б', 'Ю', ',']
|
||||
|
||||
ALB = ['а', 'у', 'о', 'ы', 'и', 'э', 'я', 'ю', 'ё', 'е', 'А', 'У', 'О', 'Ы', 'И', 'Э', 'Я', 'Ю', 'Ё', 'Е']
|
||||
# ДАННЫЕ БОТА
|
||||
TOKEN = "XXXXXXXXXX" # @chat_abobot
|
||||
DEBAG = "XXXXXXXXXX" # Технический чат
|
||||
|
||||
TEX_GROUP = "XXXXXXXXXX"
|
||||
|
||||
# ОБРАЩЕНИЯ К ПОЛЬЗОВАТЕЛЯМ
|
||||
KILL_LIST = ["побить", "отмудохать", "избить", "уебать", "отметелить"]
|
||||
TMOK_LIST = ["поцеловать", "чмокнуть", "соснуть", "лайкнуть"]
|
||||
QUAT_LIST = [['дай', 'дайте'], ['ахуенный', 'ахуеный', 'охуеный', 'охуенный', 'блять', 'сука'], ['совет', 'совета']]
|
||||
|
||||
# ФРАЗЫ ИВЕНТ ДРАКИ
|
||||
VAR_WIN = ["опустив его ниже плинтуса!", "поставив его на место!"]
|
||||
VAR_LOSE = ["Кунг - Фу!", "магии!", "резинового члена!", "банды цапель!"]
|
||||
|
||||
# ПЕРЕВОДЧИК СЛОВ
|
||||
ERR = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||
"'", 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', '`']
|
||||
ERR_ = ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':',
|
||||
'"', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', '~']
|
||||
TRU = ['й', 'ц', 'у', 'к', 'е', 'н', 'г', 'ш', 'щ', 'з', 'х', 'ъ', 'ф', 'ы', 'в', 'а', 'п', 'р', 'о', 'л', 'д', 'ж',
|
||||
'э', 'я', 'ч', 'с', 'м', 'и', 'т', 'ь', 'б', 'ю', '.']
|
||||
TRU_ = ['Й', 'Ц', 'У', 'К', 'Е', 'Н', 'Г', 'Ш', 'Щ', 'З', 'Х', 'Ъ', 'Ф', 'Ы', 'В', 'А', 'П', 'Р', 'О', 'Л', 'Д', 'Ж',
|
||||
'Э', 'Я', 'Ч', 'С', 'М', 'И', 'Т', 'Ь', 'Б', 'Ю', ',']
|
||||
|
||||
ALB = ['а', 'у', 'о', 'ы', 'и', 'э', 'я', 'ю', 'ё', 'е', 'А', 'У', 'О', 'Ы', 'И', 'Э', 'Я', 'Ю', 'Ё', 'Е']
|
||||
|
|
|
|||
338
code/script.py
338
code/script.py
|
|
@ -1,170 +1,170 @@
|
|||
from base import ERR, ERR_, TRU, TRU_, ALB
|
||||
from string import digits, punctuation
|
||||
import re, sql
|
||||
|
||||
# инициализируем соединение с БД
|
||||
db = sql.Base('../db/base.db')
|
||||
du = sql.User('../db/users.db')
|
||||
dg = sql.Group('../db/groups.db')
|
||||
dm = sql.Month('../db/month.db')
|
||||
|
||||
|
||||
def upd_stat(user_id, group_id, var_id, name, mes=False):
|
||||
name = re.sub(r'[^\w\s]', '', name.lower())
|
||||
if not du.user_exists(user_id):
|
||||
du.add_user(user_id)
|
||||
user_id = du.get_user_id(user_id)
|
||||
|
||||
if not du.group_exists(group_id):
|
||||
du.add_group(group_id)
|
||||
group_id = du.get_group_id(group_id)
|
||||
|
||||
if not db.group_exists(group_id):
|
||||
db.add_group(group_id)
|
||||
dg.created_group(group_id)
|
||||
|
||||
if not dg.user_exists(user_id, group_id):
|
||||
dg.add_user(group_id, user_id, name)
|
||||
|
||||
db.update_stat(group_id, var_id)
|
||||
dg.update_stat(user_id, group_id, var_id)
|
||||
|
||||
if not db.group_exists_month(group_id):
|
||||
db.add_group_month(group_id)
|
||||
dm.created_group(group_id)
|
||||
dm.add_user(group_id, user_id)
|
||||
else:
|
||||
if not dm.user_exists(user_id, group_id):
|
||||
dm.add_user(group_id, user_id)
|
||||
|
||||
db.update_month_stat(group_id, var_id)
|
||||
dm.update_stat(user_id, group_id, var_id)
|
||||
|
||||
if mes:
|
||||
db.update_month_stat(group_id, 1)
|
||||
dg.update_stat(user_id, group_id, 1)
|
||||
dm.update_stat(user_id, group_id, 1)
|
||||
db.update_stat(group_id, 1)
|
||||
|
||||
if not db.edit_user_exists(user_id):
|
||||
dg.update_name(user_id, group_id, name)
|
||||
|
||||
|
||||
def lang_form(text, smbl='г'):
|
||||
for i in range(len(text)):
|
||||
word = [str(j) + str(smbl) + str(j).lower() if j in ALB else str(j) for j in text[i]]
|
||||
text[i] = ''.join(word)
|
||||
return ' '.join(text)
|
||||
|
||||
|
||||
def notice(name, all_users, group_id, author):
|
||||
names = [i[0] for i in dg.all_names(group_id)]
|
||||
ids = [du.get_first_user_id(i[0]) for i in dg.all_ids(group_id)]
|
||||
|
||||
if all_users:
|
||||
name = dg.user_name(name, group_id)
|
||||
usr = [f"[{names[i].title()}](tg://user?id={str(ids[i])})" for i in range(len(names)) if names[i] != name.lower()]
|
||||
usr.append(f'{usr[-2]} и {usr[-1]}')
|
||||
del usr[-2], usr[-2]
|
||||
return f'{", ".join(usr)} вас вызывает {name.title()}'
|
||||
else:
|
||||
no_copy = []
|
||||
for i in name:
|
||||
if i not in no_copy:
|
||||
no_copy.append(i)
|
||||
|
||||
if len(no_copy) > 1: # ПЕРЕПИСАТЬ КОД ГАВНА КУСОК
|
||||
usr = [f"[{_.title()}](tg://user?id={str(ids[names.index(_)])})" for _ in no_copy if int(author) != ids[names.index(_)]]
|
||||
usr.append(f'{usr[-2]} и {usr[-1]}')
|
||||
del usr[-2], usr[-2]
|
||||
return f"{', '.join(usr)} вас упомянули)"
|
||||
else:
|
||||
usr = f"[{no_copy[0].title()}](tg://user?id={str(ids[names.index(no_copy[0])])})"
|
||||
return f"{usr}, тебя упомянули)"
|
||||
|
||||
|
||||
def checker(signs, words, group_id, user_id, name):
|
||||
if len([z for z in signs if (z in digits) or (z in punctuation)]) == len(signs) or signs[0] == '/':
|
||||
return int('-1')
|
||||
|
||||
if len(signs) > 4:
|
||||
for x in range(3, len(signs)):
|
||||
http = "".join([signs[x - 3], signs[x - 2], signs[x - 1], signs[x]])
|
||||
if 'http' in http:
|
||||
upd_stat(user_id, group_id, 4, name)
|
||||
return int('-1')
|
||||
|
||||
count, raw = 0, 0
|
||||
for word in words:
|
||||
for symbol in word:
|
||||
raw += 1
|
||||
if (symbol in ERR) or (symbol in ERR_) or (symbol in digits):
|
||||
count += 1
|
||||
return len(signs) - raw + count
|
||||
|
||||
|
||||
def translator(words):
|
||||
itg = []
|
||||
for word in words:
|
||||
raw_word = []
|
||||
for symbol in word:
|
||||
if symbol in ERR:
|
||||
count = 0
|
||||
for _ in ERR:
|
||||
if symbol == _:
|
||||
raw_word.append(TRU[count])
|
||||
break
|
||||
count += 1
|
||||
elif symbol in ERR_:
|
||||
count = 0
|
||||
for _ in ERR_:
|
||||
if symbol == _:
|
||||
raw_word.append(TRU_[count])
|
||||
break
|
||||
count += 1
|
||||
itg.append("".join(raw_word))
|
||||
return " ".join(itg)
|
||||
|
||||
|
||||
def revers(message, var):
|
||||
no_pct = re.sub(r'[^\w\s]', '', message)
|
||||
|
||||
if var:
|
||||
sml, pnc, pct, prf = [i for i in message] + [str(0)], [], [], False
|
||||
for i in sml:
|
||||
if i in punctuation or i == ' ':
|
||||
pnc.append(i)
|
||||
prf, flag = True if sml.index(i) == 0 else False, False
|
||||
else:
|
||||
flag = True
|
||||
|
||||
if flag and len(pnc) > 0:
|
||||
pct.append(''.join(pnc))
|
||||
pnc = []
|
||||
|
||||
wrd, rev, lst, txt = no_pct.split(), [], [], []
|
||||
for i in wrd:
|
||||
word, up, itg = [i[-1 - l].lower() for l in range(len(i))], [], []
|
||||
|
||||
for _ in i:
|
||||
up.append(True if _ in TRU_ else False)
|
||||
for j in range(len(up)):
|
||||
itg.append(word[j].upper() if up[j] else word[j])
|
||||
|
||||
rev.append(''.join(itg))
|
||||
|
||||
if prf:
|
||||
for i in range(len(pct)):
|
||||
txt = (txt + [pct[i]]) if (i + 1) == len(pct) and len(pct) > len(rev) else (txt + [pct[i], rev[i]])
|
||||
return ''.join(txt)
|
||||
else:
|
||||
for i in range(len(rev)):
|
||||
if i > 0:
|
||||
txt.append(pct[i - 1])
|
||||
txt.append(rev[i])
|
||||
if (i + 1) == len(rev) and len(pct) == len(rev):
|
||||
txt.append(pct[i])
|
||||
return ''.join(txt)
|
||||
else:
|
||||
sml = [i for i in message]
|
||||
from base import ERR, ERR_, TRU, TRU_, ALB
|
||||
from string import digits, punctuation
|
||||
import re, sql
|
||||
|
||||
# инициализируем соединение с БД
|
||||
db = sql.Base('../db/base.db')
|
||||
du = sql.User('../db/users.db')
|
||||
dg = sql.Group('../db/groups.db')
|
||||
dm = sql.Month('../db/month.db')
|
||||
|
||||
|
||||
def upd_stat(user_id, group_id, var_id, name, mes=False):
|
||||
name = re.sub(r'[^\w\s]', '', name.lower())
|
||||
if not du.user_exists(user_id):
|
||||
du.add_user(user_id)
|
||||
user_id = du.get_user_id(user_id)
|
||||
|
||||
if not du.group_exists(group_id):
|
||||
du.add_group(group_id)
|
||||
group_id = du.get_group_id(group_id)
|
||||
|
||||
if not db.group_exists(group_id):
|
||||
db.add_group(group_id)
|
||||
dg.created_group(group_id)
|
||||
|
||||
if not dg.user_exists(user_id, group_id):
|
||||
dg.add_user(group_id, user_id, name)
|
||||
|
||||
db.update_stat(group_id, var_id)
|
||||
dg.update_stat(user_id, group_id, var_id)
|
||||
|
||||
if not db.group_exists_month(group_id):
|
||||
db.add_group_month(group_id)
|
||||
dm.created_group(group_id)
|
||||
dm.add_user(group_id, user_id)
|
||||
else:
|
||||
if not dm.user_exists(user_id, group_id):
|
||||
dm.add_user(group_id, user_id)
|
||||
|
||||
db.update_month_stat(group_id, var_id)
|
||||
dm.update_stat(user_id, group_id, var_id)
|
||||
|
||||
if mes:
|
||||
db.update_month_stat(group_id, 1)
|
||||
dg.update_stat(user_id, group_id, 1)
|
||||
dm.update_stat(user_id, group_id, 1)
|
||||
db.update_stat(group_id, 1)
|
||||
|
||||
if not db.edit_user_exists(user_id):
|
||||
dg.update_name(user_id, group_id, name)
|
||||
|
||||
|
||||
def lang_form(text, smbl='г'):
|
||||
for i in range(len(text)):
|
||||
word = [str(j) + str(smbl) + str(j).lower() if j in ALB else str(j) for j in text[i]]
|
||||
text[i] = ''.join(word)
|
||||
return ' '.join(text)
|
||||
|
||||
|
||||
def notice(name, all_users, group_id, author):
|
||||
names = [i[0] for i in dg.all_names(group_id)]
|
||||
ids = [du.get_first_user_id(i[0]) for i in dg.all_ids(group_id)]
|
||||
|
||||
if all_users:
|
||||
name = dg.user_name(name, group_id)
|
||||
usr = [f"[{names[i].title()}](tg://user?id={str(ids[i])})" for i in range(len(names)) if names[i] != name.lower()]
|
||||
usr.append(f'{usr[-2]} и {usr[-1]}')
|
||||
del usr[-2], usr[-2]
|
||||
return f'{", ".join(usr)} вас вызывает {name.title()}'
|
||||
else:
|
||||
no_copy = []
|
||||
for i in name:
|
||||
if i not in no_copy:
|
||||
no_copy.append(i)
|
||||
|
||||
if len(no_copy) > 1: # ПЕРЕПИСАТЬ КОД ГАВНА КУСОК
|
||||
usr = [f"[{_.title()}](tg://user?id={str(ids[names.index(_)])})" for _ in no_copy if int(author) != ids[names.index(_)]]
|
||||
usr.append(f'{usr[-2]} и {usr[-1]}')
|
||||
del usr[-2], usr[-2]
|
||||
return f"{', '.join(usr)} вас упомянули)"
|
||||
else:
|
||||
usr = f"[{no_copy[0].title()}](tg://user?id={str(ids[names.index(no_copy[0])])})"
|
||||
return f"{usr}, тебя упомянули)"
|
||||
|
||||
|
||||
def checker(signs, words, group_id, user_id, name):
|
||||
if len([z for z in signs if (z in digits) or (z in punctuation)]) == len(signs) or signs[0] == '/':
|
||||
return int('-1')
|
||||
|
||||
if len(signs) > 4:
|
||||
for x in range(3, len(signs)):
|
||||
http = "".join([signs[x - 3], signs[x - 2], signs[x - 1], signs[x]])
|
||||
if 'http' in http:
|
||||
upd_stat(user_id, group_id, 4, name)
|
||||
return int('-1')
|
||||
|
||||
count, raw = 0, 0
|
||||
for word in words:
|
||||
for symbol in word:
|
||||
raw += 1
|
||||
if (symbol in ERR) or (symbol in ERR_) or (symbol in digits):
|
||||
count += 1
|
||||
return len(signs) - raw + count
|
||||
|
||||
|
||||
def translator(words):
|
||||
itg = []
|
||||
for word in words:
|
||||
raw_word = []
|
||||
for symbol in word:
|
||||
if symbol in ERR:
|
||||
count = 0
|
||||
for _ in ERR:
|
||||
if symbol == _:
|
||||
raw_word.append(TRU[count])
|
||||
break
|
||||
count += 1
|
||||
elif symbol in ERR_:
|
||||
count = 0
|
||||
for _ in ERR_:
|
||||
if symbol == _:
|
||||
raw_word.append(TRU_[count])
|
||||
break
|
||||
count += 1
|
||||
itg.append("".join(raw_word))
|
||||
return " ".join(itg)
|
||||
|
||||
|
||||
def revers(message, var):
|
||||
no_pct = re.sub(r'[^\w\s]', '', message)
|
||||
|
||||
if var:
|
||||
sml, pnc, pct, prf = [i for i in message] + [str(0)], [], [], False
|
||||
for i in sml:
|
||||
if i in punctuation or i == ' ':
|
||||
pnc.append(i)
|
||||
prf, flag = True if sml.index(i) == 0 else False, False
|
||||
else:
|
||||
flag = True
|
||||
|
||||
if flag and len(pnc) > 0:
|
||||
pct.append(''.join(pnc))
|
||||
pnc = []
|
||||
|
||||
wrd, rev, lst, txt = no_pct.split(), [], [], []
|
||||
for i in wrd:
|
||||
word, up, itg = [i[-1 - l].lower() for l in range(len(i))], [], []
|
||||
|
||||
for _ in i:
|
||||
up.append(True if _ in TRU_ else False)
|
||||
for j in range(len(up)):
|
||||
itg.append(word[j].upper() if up[j] else word[j])
|
||||
|
||||
rev.append(''.join(itg))
|
||||
|
||||
if prf:
|
||||
for i in range(len(pct)):
|
||||
txt = (txt + [pct[i]]) if (i + 1) == len(pct) and len(pct) > len(rev) else (txt + [pct[i], rev[i]])
|
||||
return ''.join(txt)
|
||||
else:
|
||||
for i in range(len(rev)):
|
||||
if i > 0:
|
||||
txt.append(pct[i - 1])
|
||||
txt.append(rev[i])
|
||||
if (i + 1) == len(rev) and len(pct) == len(rev):
|
||||
txt.append(pct[i])
|
||||
return ''.join(txt)
|
||||
else:
|
||||
sml = [i for i in message]
|
||||
return ''.join([sml[-1 - i] for i in range(len(sml))])
|
||||
Binary file not shown.
Loading…
Add table
Reference in a new issue