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
|
TOKEN = "XXXXXXXXXX" # @chat_abobot
|
||||||
DEBAG = "XXXXXXXXXX" # Технический чат
|
DEBAG = "XXXXXXXXXX" # Технический чат
|
||||||
|
|
||||||
TEX_GROUP = "XXXXXXXXXX"
|
TEX_GROUP = "XXXXXXXXXX"
|
||||||
|
|
||||||
# ОБРАЩЕНИЯ К ПОЛЬЗОВАТЕЛЯМ
|
# ОБРАЩЕНИЯ К ПОЛЬЗОВАТЕЛЯМ
|
||||||
KILL_LIST = ["побить", "отмудохать", "избить", "уебать", "отметелить"]
|
KILL_LIST = ["побить", "отмудохать", "избить", "уебать", "отметелить"]
|
||||||
TMOK_LIST = ["поцеловать", "чмокнуть", "соснуть", "лайкнуть"]
|
TMOK_LIST = ["поцеловать", "чмокнуть", "соснуть", "лайкнуть"]
|
||||||
QUAT_LIST = [['дай', 'дайте'], ['ахуенный', 'ахуеный', 'охуеный', 'охуенный', 'блять', 'сука'], ['совет', 'совета']]
|
QUAT_LIST = [['дай', 'дайте'], ['ахуенный', 'ахуеный', 'охуеный', 'охуенный', 'блять', 'сука'], ['совет', 'совета']]
|
||||||
|
|
||||||
# ФРАЗЫ ИВЕНТ ДРАКИ
|
# ФРАЗЫ ИВЕНТ ДРАКИ
|
||||||
VAR_WIN = ["опустив его ниже плинтуса!", "поставив его на место!"]
|
VAR_WIN = ["опустив его ниже плинтуса!", "поставив его на место!"]
|
||||||
VAR_LOSE = ["Кунг - Фу!", "магии!", "резинового члена!", "банды цапель!"]
|
VAR_LOSE = ["Кунг - Фу!", "магии!", "резинового члена!", "банды цапель!"]
|
||||||
|
|
||||||
# ПЕРЕВОДЧИК СЛОВ
|
# ПЕРЕВОДЧИК СЛОВ
|
||||||
ERR = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
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', ',', '.', '/', '`']
|
"'", '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', ':',
|
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', '<', '>', '?', '~']
|
'"', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', '~']
|
||||||
TRU = ['й', 'ц', 'у', 'к', 'е', 'н', 'г', 'ш', 'щ', 'з', 'х', 'ъ', 'ф', 'ы', 'в', 'а', 'п', 'р', 'о', 'л', 'д', 'ж',
|
TRU = ['й', 'ц', 'у', 'к', 'е', 'н', 'г', 'ш', 'щ', 'з', 'х', 'ъ', 'ф', 'ы', 'в', 'а', 'п', 'р', 'о', 'л', 'д', 'ж',
|
||||||
'э', 'я', 'ч', 'с', 'м', 'и', 'т', 'ь', 'б', 'ю', '.']
|
'э', 'я', 'ч', 'с', 'м', 'и', 'т', 'ь', 'б', 'ю', '.']
|
||||||
TRU_ = ['Й', 'Ц', 'У', 'К', 'Е', 'Н', 'Г', 'Ш', 'Щ', 'З', 'Х', 'Ъ', 'Ф', 'Ы', 'В', 'А', 'П', 'Р', 'О', 'Л', 'Д', 'Ж',
|
TRU_ = ['Й', 'Ц', 'У', 'К', 'Е', 'Н', 'Г', 'Ш', 'Щ', 'З', 'Х', 'Ъ', 'Ф', 'Ы', 'В', 'А', 'П', 'Р', 'О', 'Л', 'Д', 'Ж',
|
||||||
'Э', 'Я', 'Ч', 'С', 'М', 'И', 'Т', 'Ь', 'Б', 'Ю', ',']
|
'Э', 'Я', 'Ч', 'С', 'М', 'И', 'Т', 'Ь', 'Б', 'Ю', ',']
|
||||||
|
|
||||||
ALB = ['а', 'у', 'о', 'ы', 'и', 'э', 'я', 'ю', 'ё', 'е', 'А', 'У', 'О', 'Ы', 'И', 'Э', 'Я', 'Ю', 'Ё', 'Е']
|
ALB = ['а', 'у', 'о', 'ы', 'и', 'э', 'я', 'ю', 'ё', 'е', 'А', 'У', 'О', 'Ы', 'И', 'Э', 'Я', 'Ю', 'Ё', 'Е']
|
||||||
|
|
|
||||||
338
code/script.py
338
code/script.py
|
|
@ -1,170 +1,170 @@
|
||||||
from base import ERR, ERR_, TRU, TRU_, ALB
|
from base import ERR, ERR_, TRU, TRU_, ALB
|
||||||
from string import digits, punctuation
|
from string import digits, punctuation
|
||||||
import re, sql
|
import re, sql
|
||||||
|
|
||||||
# инициализируем соединение с БД
|
# инициализируем соединение с БД
|
||||||
db = sql.Base('../db/base.db')
|
db = sql.Base('../db/base.db')
|
||||||
du = sql.User('../db/users.db')
|
du = sql.User('../db/users.db')
|
||||||
dg = sql.Group('../db/groups.db')
|
dg = sql.Group('../db/groups.db')
|
||||||
dm = sql.Month('../db/month.db')
|
dm = sql.Month('../db/month.db')
|
||||||
|
|
||||||
|
|
||||||
def upd_stat(user_id, group_id, var_id, name, mes=False):
|
def upd_stat(user_id, group_id, var_id, name, mes=False):
|
||||||
name = re.sub(r'[^\w\s]', '', name.lower())
|
name = re.sub(r'[^\w\s]', '', name.lower())
|
||||||
if not du.user_exists(user_id):
|
if not du.user_exists(user_id):
|
||||||
du.add_user(user_id)
|
du.add_user(user_id)
|
||||||
user_id = du.get_user_id(user_id)
|
user_id = du.get_user_id(user_id)
|
||||||
|
|
||||||
if not du.group_exists(group_id):
|
if not du.group_exists(group_id):
|
||||||
du.add_group(group_id)
|
du.add_group(group_id)
|
||||||
group_id = du.get_group_id(group_id)
|
group_id = du.get_group_id(group_id)
|
||||||
|
|
||||||
if not db.group_exists(group_id):
|
if not db.group_exists(group_id):
|
||||||
db.add_group(group_id)
|
db.add_group(group_id)
|
||||||
dg.created_group(group_id)
|
dg.created_group(group_id)
|
||||||
|
|
||||||
if not dg.user_exists(user_id, group_id):
|
if not dg.user_exists(user_id, group_id):
|
||||||
dg.add_user(group_id, user_id, name)
|
dg.add_user(group_id, user_id, name)
|
||||||
|
|
||||||
db.update_stat(group_id, var_id)
|
db.update_stat(group_id, var_id)
|
||||||
dg.update_stat(user_id, group_id, var_id)
|
dg.update_stat(user_id, group_id, var_id)
|
||||||
|
|
||||||
if not db.group_exists_month(group_id):
|
if not db.group_exists_month(group_id):
|
||||||
db.add_group_month(group_id)
|
db.add_group_month(group_id)
|
||||||
dm.created_group(group_id)
|
dm.created_group(group_id)
|
||||||
dm.add_user(group_id, user_id)
|
dm.add_user(group_id, user_id)
|
||||||
else:
|
else:
|
||||||
if not dm.user_exists(user_id, group_id):
|
if not dm.user_exists(user_id, group_id):
|
||||||
dm.add_user(group_id, user_id)
|
dm.add_user(group_id, user_id)
|
||||||
|
|
||||||
db.update_month_stat(group_id, var_id)
|
db.update_month_stat(group_id, var_id)
|
||||||
dm.update_stat(user_id, group_id, var_id)
|
dm.update_stat(user_id, group_id, var_id)
|
||||||
|
|
||||||
if mes:
|
if mes:
|
||||||
db.update_month_stat(group_id, 1)
|
db.update_month_stat(group_id, 1)
|
||||||
dg.update_stat(user_id, group_id, 1)
|
dg.update_stat(user_id, group_id, 1)
|
||||||
dm.update_stat(user_id, group_id, 1)
|
dm.update_stat(user_id, group_id, 1)
|
||||||
db.update_stat(group_id, 1)
|
db.update_stat(group_id, 1)
|
||||||
|
|
||||||
if not db.edit_user_exists(user_id):
|
if not db.edit_user_exists(user_id):
|
||||||
dg.update_name(user_id, group_id, name)
|
dg.update_name(user_id, group_id, name)
|
||||||
|
|
||||||
|
|
||||||
def lang_form(text, smbl='г'):
|
def lang_form(text, smbl='г'):
|
||||||
for i in range(len(text)):
|
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]]
|
word = [str(j) + str(smbl) + str(j).lower() if j in ALB else str(j) for j in text[i]]
|
||||||
text[i] = ''.join(word)
|
text[i] = ''.join(word)
|
||||||
return ' '.join(text)
|
return ' '.join(text)
|
||||||
|
|
||||||
|
|
||||||
def notice(name, all_users, group_id, author):
|
def notice(name, all_users, group_id, author):
|
||||||
names = [i[0] for i in dg.all_names(group_id)]
|
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)]
|
ids = [du.get_first_user_id(i[0]) for i in dg.all_ids(group_id)]
|
||||||
|
|
||||||
if all_users:
|
if all_users:
|
||||||
name = dg.user_name(name, group_id)
|
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 = [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]}')
|
usr.append(f'{usr[-2]} и {usr[-1]}')
|
||||||
del usr[-2], usr[-2]
|
del usr[-2], usr[-2]
|
||||||
return f'{", ".join(usr)} вас вызывает {name.title()}'
|
return f'{", ".join(usr)} вас вызывает {name.title()}'
|
||||||
else:
|
else:
|
||||||
no_copy = []
|
no_copy = []
|
||||||
for i in name:
|
for i in name:
|
||||||
if i not in no_copy:
|
if i not in no_copy:
|
||||||
no_copy.append(i)
|
no_copy.append(i)
|
||||||
|
|
||||||
if len(no_copy) > 1: # ПЕРЕПИСАТЬ КОД ГАВНА КУСОК
|
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 = [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]}')
|
usr.append(f'{usr[-2]} и {usr[-1]}')
|
||||||
del usr[-2], usr[-2]
|
del usr[-2], usr[-2]
|
||||||
return f"{', '.join(usr)} вас упомянули)"
|
return f"{', '.join(usr)} вас упомянули)"
|
||||||
else:
|
else:
|
||||||
usr = f"[{no_copy[0].title()}](tg://user?id={str(ids[names.index(no_copy[0])])})"
|
usr = f"[{no_copy[0].title()}](tg://user?id={str(ids[names.index(no_copy[0])])})"
|
||||||
return f"{usr}, тебя упомянули)"
|
return f"{usr}, тебя упомянули)"
|
||||||
|
|
||||||
|
|
||||||
def checker(signs, words, group_id, user_id, name):
|
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] == '/':
|
if len([z for z in signs if (z in digits) or (z in punctuation)]) == len(signs) or signs[0] == '/':
|
||||||
return int('-1')
|
return int('-1')
|
||||||
|
|
||||||
if len(signs) > 4:
|
if len(signs) > 4:
|
||||||
for x in range(3, len(signs)):
|
for x in range(3, len(signs)):
|
||||||
http = "".join([signs[x - 3], signs[x - 2], signs[x - 1], signs[x]])
|
http = "".join([signs[x - 3], signs[x - 2], signs[x - 1], signs[x]])
|
||||||
if 'http' in http:
|
if 'http' in http:
|
||||||
upd_stat(user_id, group_id, 4, name)
|
upd_stat(user_id, group_id, 4, name)
|
||||||
return int('-1')
|
return int('-1')
|
||||||
|
|
||||||
count, raw = 0, 0
|
count, raw = 0, 0
|
||||||
for word in words:
|
for word in words:
|
||||||
for symbol in word:
|
for symbol in word:
|
||||||
raw += 1
|
raw += 1
|
||||||
if (symbol in ERR) or (symbol in ERR_) or (symbol in digits):
|
if (symbol in ERR) or (symbol in ERR_) or (symbol in digits):
|
||||||
count += 1
|
count += 1
|
||||||
return len(signs) - raw + count
|
return len(signs) - raw + count
|
||||||
|
|
||||||
|
|
||||||
def translator(words):
|
def translator(words):
|
||||||
itg = []
|
itg = []
|
||||||
for word in words:
|
for word in words:
|
||||||
raw_word = []
|
raw_word = []
|
||||||
for symbol in word:
|
for symbol in word:
|
||||||
if symbol in ERR:
|
if symbol in ERR:
|
||||||
count = 0
|
count = 0
|
||||||
for _ in ERR:
|
for _ in ERR:
|
||||||
if symbol == _:
|
if symbol == _:
|
||||||
raw_word.append(TRU[count])
|
raw_word.append(TRU[count])
|
||||||
break
|
break
|
||||||
count += 1
|
count += 1
|
||||||
elif symbol in ERR_:
|
elif symbol in ERR_:
|
||||||
count = 0
|
count = 0
|
||||||
for _ in ERR_:
|
for _ in ERR_:
|
||||||
if symbol == _:
|
if symbol == _:
|
||||||
raw_word.append(TRU_[count])
|
raw_word.append(TRU_[count])
|
||||||
break
|
break
|
||||||
count += 1
|
count += 1
|
||||||
itg.append("".join(raw_word))
|
itg.append("".join(raw_word))
|
||||||
return " ".join(itg)
|
return " ".join(itg)
|
||||||
|
|
||||||
|
|
||||||
def revers(message, var):
|
def revers(message, var):
|
||||||
no_pct = re.sub(r'[^\w\s]', '', message)
|
no_pct = re.sub(r'[^\w\s]', '', message)
|
||||||
|
|
||||||
if var:
|
if var:
|
||||||
sml, pnc, pct, prf = [i for i in message] + [str(0)], [], [], False
|
sml, pnc, pct, prf = [i for i in message] + [str(0)], [], [], False
|
||||||
for i in sml:
|
for i in sml:
|
||||||
if i in punctuation or i == ' ':
|
if i in punctuation or i == ' ':
|
||||||
pnc.append(i)
|
pnc.append(i)
|
||||||
prf, flag = True if sml.index(i) == 0 else False, False
|
prf, flag = True if sml.index(i) == 0 else False, False
|
||||||
else:
|
else:
|
||||||
flag = True
|
flag = True
|
||||||
|
|
||||||
if flag and len(pnc) > 0:
|
if flag and len(pnc) > 0:
|
||||||
pct.append(''.join(pnc))
|
pct.append(''.join(pnc))
|
||||||
pnc = []
|
pnc = []
|
||||||
|
|
||||||
wrd, rev, lst, txt = no_pct.split(), [], [], []
|
wrd, rev, lst, txt = no_pct.split(), [], [], []
|
||||||
for i in wrd:
|
for i in wrd:
|
||||||
word, up, itg = [i[-1 - l].lower() for l in range(len(i))], [], []
|
word, up, itg = [i[-1 - l].lower() for l in range(len(i))], [], []
|
||||||
|
|
||||||
for _ in i:
|
for _ in i:
|
||||||
up.append(True if _ in TRU_ else False)
|
up.append(True if _ in TRU_ else False)
|
||||||
for j in range(len(up)):
|
for j in range(len(up)):
|
||||||
itg.append(word[j].upper() if up[j] else word[j])
|
itg.append(word[j].upper() if up[j] else word[j])
|
||||||
|
|
||||||
rev.append(''.join(itg))
|
rev.append(''.join(itg))
|
||||||
|
|
||||||
if prf:
|
if prf:
|
||||||
for i in range(len(pct)):
|
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]])
|
txt = (txt + [pct[i]]) if (i + 1) == len(pct) and len(pct) > len(rev) else (txt + [pct[i], rev[i]])
|
||||||
return ''.join(txt)
|
return ''.join(txt)
|
||||||
else:
|
else:
|
||||||
for i in range(len(rev)):
|
for i in range(len(rev)):
|
||||||
if i > 0:
|
if i > 0:
|
||||||
txt.append(pct[i - 1])
|
txt.append(pct[i - 1])
|
||||||
txt.append(rev[i])
|
txt.append(rev[i])
|
||||||
if (i + 1) == len(rev) and len(pct) == len(rev):
|
if (i + 1) == len(rev) and len(pct) == len(rev):
|
||||||
txt.append(pct[i])
|
txt.append(pct[i])
|
||||||
return ''.join(txt)
|
return ''.join(txt)
|
||||||
else:
|
else:
|
||||||
sml = [i for i in message]
|
sml = [i for i in message]
|
||||||
return ''.join([sml[-1 - i] for i in range(len(sml))])
|
return ''.join([sml[-1 - i] for i in range(len(sml))])
|
||||||
Binary file not shown.
Loading…
Add table
Reference in a new issue