|
|
@ -50,111 +50,116 @@ def start(message):
|
|
|
|
def reg(message):
|
|
|
|
def reg(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
db = load()
|
|
|
|
db = load()
|
|
|
|
if len(message.text.split()) == 2:
|
|
|
|
if not ok_args(bot, message, 2, '```\n/reg никнейм```'):
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
return 0
|
|
|
|
# Проверка ника
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
if not nick_ok(bot, message, nick):
|
|
|
|
# Проверка ника
|
|
|
|
return 0
|
|
|
|
if not nick_ok(bot, message, nick):
|
|
|
|
if nick in db:
|
|
|
|
return 0
|
|
|
|
bot.reply_to(message, "Данный пользователь уже зарегистрирован.")
|
|
|
|
if nick in db:
|
|
|
|
elif str(message.chat.id) in db:
|
|
|
|
bot.reply_to(message, "Данный пользователь уже зарегистрирован.")
|
|
|
|
bot.reply_to(message, "Вы уже зарегистрированы.")
|
|
|
|
elif str(message.chat.id) in db:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message, "Вы уже зарегистрированы.")
|
|
|
|
user = user_(message.chat.id, hash(randint(74287, 5747962)))
|
|
|
|
|
|
|
|
db[nick] = user
|
|
|
|
|
|
|
|
db[message.chat.id] = nick
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
bot.reply_to(message, "Вы зарегистрировались!\nПриятного использования.")
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message, "Вы ввели не 2 аргумента, нужно: /reg ЛюбойНикнейм")
|
|
|
|
user = user_(message.chat.id, hash(randint(74287, 5747962)))
|
|
|
|
|
|
|
|
db[nick] = user
|
|
|
|
|
|
|
|
db[message.chat.id] = nick
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
bot.reply_to(message, "Вы зарегистрировались!\nПриятного использования.")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(bot, message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['b'])
|
|
|
|
@bot.message_handler(commands=['b'])
|
|
|
|
def b(message):
|
|
|
|
def b(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if is_auth(bot, message):
|
|
|
|
if not is_auth(bot, message) or not ok_args(bot, message, 2, '```\n/b :ник``` или ```\n/b ник```'):
|
|
|
|
db = load()
|
|
|
|
return 0
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
db = load()
|
|
|
|
user = db[nick]
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
block = message.text.split()[1]
|
|
|
|
user = db[nick]
|
|
|
|
|
|
|
|
block = message.text.split()[1]
|
|
|
|
# Block by ":user"
|
|
|
|
|
|
|
|
if block[0] == ":":
|
|
|
|
# Block by ":user"
|
|
|
|
block = block[1:]
|
|
|
|
if block[0] == ":":
|
|
|
|
|
|
|
|
block = block[1:]
|
|
|
|
if block in db:
|
|
|
|
|
|
|
|
if db[block].id not in user.blocks:
|
|
|
|
if block in db:
|
|
|
|
user.blocks.append(db[block].id)
|
|
|
|
if db[block].id not in user.blocks:
|
|
|
|
save(db)
|
|
|
|
user.blocks.append(db[block].id)
|
|
|
|
bot.reply_to(message, f"Пользователь {telebot.formatting.hcode(block)} был заблокирован.",parse_mode="HTML")
|
|
|
|
save(db)
|
|
|
|
else:
|
|
|
|
bot.reply_to(message, f"Пользователь {telebot.formatting.hcode(block)} был заблокирован.",parse_mode="HTML")
|
|
|
|
bot.reply_to(message, "Данного пользователя не существует.")
|
|
|
|
else:
|
|
|
|
|
|
|
|
bot.reply_to(message, "Данного пользователя не существует.")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(bot, message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['u'])
|
|
|
|
@bot.message_handler(commands=['u'])
|
|
|
|
def u(message):
|
|
|
|
def u(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if is_auth(bot, message):
|
|
|
|
if not is_auth(bot, message) or not ok_args(bot, message, 2, '```\n/u :ник``` или ```\n/u ник```'):
|
|
|
|
db = load()
|
|
|
|
return 0
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
db = load()
|
|
|
|
user = db[nick]
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
block = message.text.split()[1]
|
|
|
|
user = db[nick]
|
|
|
|
|
|
|
|
block = message.text.split()[1]
|
|
|
|
|
|
|
|
|
|
|
|
# Unblock by ":user"
|
|
|
|
# Unblock by ":user"
|
|
|
|
if block[0] == ":":
|
|
|
|
if block[0] == ":":
|
|
|
|
block = block[1:]
|
|
|
|
block = block[1:]
|
|
|
|
|
|
|
|
|
|
|
|
if db[block].id in user.blocks:
|
|
|
|
if block in db and db[block].id in user.blocks:
|
|
|
|
user.blocks.remove(db[block].id)
|
|
|
|
user.blocks.remove(db[block].id)
|
|
|
|
save(db)
|
|
|
|
save(db)
|
|
|
|
bot.reply_to(message, f"Была снята блокировка с пользователя {telebot.formatting.hcode(block)}",parse_mode="HTML")
|
|
|
|
bot.reply_to(message, f"Была снята блокировка с пользователя {telebot.formatting.hcode(block)}",parse_mode="HTML")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
bot.reply_to(message, "Данного пользователя не существует.")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(bot, message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['nick'])
|
|
|
|
@bot.message_handler(commands=['nick'])
|
|
|
|
def nick(message):
|
|
|
|
def nick(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if is_auth(bot, message):
|
|
|
|
if not is_auth(bot, message) or not ok_args(bot, message, 2, '```\n/nick ник```'):
|
|
|
|
db = load()
|
|
|
|
return 0
|
|
|
|
new_nick = message.text.split()[1]
|
|
|
|
db = load()
|
|
|
|
# Проверка ника
|
|
|
|
new_nick = message.text.split()[1]
|
|
|
|
if not nick_ok(message, new_nick):
|
|
|
|
# Проверка ника
|
|
|
|
return 0
|
|
|
|
if not nick_ok(bot, message, new_nick):
|
|
|
|
old_nick = db[str(message.chat.id)]
|
|
|
|
return 0
|
|
|
|
|
|
|
|
old_nick = db[str(message.chat.id)]
|
|
|
|
if new_nick not in db:
|
|
|
|
|
|
|
|
db[new_nick] = db[old_nick]
|
|
|
|
if new_nick not in db:
|
|
|
|
db[new_nick].avatar = "♿️"
|
|
|
|
db[new_nick] = db[old_nick]
|
|
|
|
db[str(message.chat.id)] = new_nick
|
|
|
|
db[new_nick].avatar = "♿️"
|
|
|
|
del db[old_nick]
|
|
|
|
db[str(message.chat.id)] = new_nick
|
|
|
|
save(db)
|
|
|
|
del db[old_nick]
|
|
|
|
bot.reply_to(message,f"Вы успешно сменили ник с {telebot.formatting.hcode(old_nick)} на {telebot.formatting.hcode(new_nick)}",parse_mode="HTML")
|
|
|
|
save(db)
|
|
|
|
bot.reply_to(message, """Ваша аватарка сброшена до стандартной: ♿️
|
|
|
|
bot.reply_to(message,f"Вы успешно сменили ник с {telebot.formatting.hcode(old_nick)} на {telebot.formatting.hcode(new_nick)}",parse_mode="HTML")
|
|
|
|
|
|
|
|
bot.reply_to(message, """Ваша аватарка сброшена до стандартной: ♿️
|
|
|
|
Также вы можете сбросить публичный ключ: /key_res""")
|
|
|
|
Также вы можете сбросить публичный ключ: /key_res""")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message,"Данный ник уже занят")
|
|
|
|
bot.reply_to(message,"Данный ник уже занят")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(bot, message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['av'])
|
|
|
|
@bot.message_handler(commands=['av'])
|
|
|
|
def av(message):
|
|
|
|
def av(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if is_auth(bot, message):
|
|
|
|
if not is_auth(bot, message) or not ok_args(bot, message, 2, '```\n/av ❄️```'):
|
|
|
|
db = load()
|
|
|
|
return 0
|
|
|
|
if not len(message.text.split()) > 1:
|
|
|
|
db = load()
|
|
|
|
bot.reply_to(message,"Укажите аватарку")
|
|
|
|
if not len(message.text.split()) > 1:
|
|
|
|
return 0
|
|
|
|
bot.reply_to(message,"Укажите аватарку")
|
|
|
|
new_avatar = message.text.split()[1]
|
|
|
|
return 0
|
|
|
|
if len(new_avatar) > 10:
|
|
|
|
new_avatar = message.text.split()[1]
|
|
|
|
bot.reply_to(message,"Слишком большое количество символов для аватарки")
|
|
|
|
if len(new_avatar) > 10:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message,"Слишком большое количество символов для аватарки")
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
else:
|
|
|
|
db[nick].avatar = new_avatar
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
save(db)
|
|
|
|
db[nick].avatar = new_avatar
|
|
|
|
bot.reply_to(message,"Новая аватарка успешно установлена")
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
bot.reply_to(message,"Новая аватарка успешно установлена")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(bot, message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
@ -163,54 +168,53 @@ def av(message):
|
|
|
|
@bot.message_handler(commands=['key'])
|
|
|
|
@bot.message_handler(commands=['key'])
|
|
|
|
def key(message):
|
|
|
|
def key(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if len(message.text.split()) == 2:
|
|
|
|
if not is_auth(bot, message) or not ok_args(bot, message, 2, '```\n/key ник``` или ```\n/key :ник```'):
|
|
|
|
db = load()
|
|
|
|
return 0
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
db = load()
|
|
|
|
if nick[0] == ':':
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
nick = nick[1:]
|
|
|
|
if nick[0] == ':':
|
|
|
|
key = db[nick].pkey
|
|
|
|
nick = nick[1:]
|
|
|
|
bot.reply_to(message,f"Ключ пользователя: {telebot.formatting.hcode(key)}", parse_mode="HTML")
|
|
|
|
key = db[nick].pkey
|
|
|
|
else:
|
|
|
|
bot.reply_to(message,f"Ключ пользователя: {telebot.formatting.hcode(key)}", parse_mode="HTML")
|
|
|
|
bot.reply_to(message,"/key ник")
|
|
|
|
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(bot, message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['ver'])
|
|
|
|
@bot.message_handler(commands=['ver'])
|
|
|
|
def ver(message):
|
|
|
|
def ver(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if len(message.text.split()) == 3:
|
|
|
|
if not is_auth(bot, message) or not ok_args(bot, message, 3, '```\n/ver ник ключ``` или ```\n/ver :ник ключ```'):
|
|
|
|
db = load()
|
|
|
|
return 0
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
db = load()
|
|
|
|
if nick[0] == ':':
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
nick = nick[1:]
|
|
|
|
if nick[0] == ':':
|
|
|
|
key = message.text.split()[2]
|
|
|
|
nick = nick[1:]
|
|
|
|
if not nick in db:
|
|
|
|
key = message.text.split()[2]
|
|
|
|
bot.reply_to(message,"Не существует такого пользователя")
|
|
|
|
if not nick in db:
|
|
|
|
return 0
|
|
|
|
bot.reply_to(message,"Не существует такого пользователя")
|
|
|
|
|
|
|
|
return 0
|
|
|
|
if key == db[nick].pkey:
|
|
|
|
|
|
|
|
bot.reply_to(message,"✅ Ключи совпадают")
|
|
|
|
if key == db[nick].pkey:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message,"✅ Ключи совпадают")
|
|
|
|
bot.reply_to(message,"❌ Ключи не совпадают")
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message,"/ver ник ключ")
|
|
|
|
bot.reply_to(message,"❌ Ключи не совпадают")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(bot, message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['key_res'])
|
|
|
|
@bot.message_handler(commands=['key_res'])
|
|
|
|
def key_res(message):
|
|
|
|
def key_res(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if is_auth(bot, message):
|
|
|
|
if not is_auth(bot, message) or not ok_args(bot, message, 1, '```\n/key_res```'):
|
|
|
|
db = load()
|
|
|
|
return 0
|
|
|
|
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
|
|
|
|
key = hash(randint(74287, 5747962))
|
|
|
|
key = hash(randint(74287, 5747962))
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
old_key = db[nick].pkey
|
|
|
|
old_key = db[nick].pkey
|
|
|
|
|
|
|
|
|
|
|
|
db[nick].pkey = key
|
|
|
|
db[nick].pkey = key
|
|
|
|
save(db)
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
|
|
|
|
bot.reply_to(message,f"""🔑 Ключ успешно сброшен.
|
|
|
|
bot.reply_to(message,f"""🔑 Ключ успешно сброшен.
|
|
|
|
|
|
|
|
|
|
|
|
Старый ключ: {telebot.formatting.hcode(old_key)}
|
|
|
|
Старый ключ: {telebot.formatting.hcode(old_key)}
|
|
|
|
Новый ключ: {telebot.formatting.hcode(key)}""",parse_mode="HTML")
|
|
|
|
Новый ключ: {telebot.formatting.hcode(key)}""",parse_mode="HTML")
|
|
|
@ -223,15 +227,16 @@ def key_res(message):
|
|
|
|
@bot.message_handler(commands=['me'])
|
|
|
|
@bot.message_handler(commands=['me'])
|
|
|
|
def me(message):
|
|
|
|
def me(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if is_auth(bot, message):
|
|
|
|
if not is_auth(bot, message) or not ok_args(bot, message, 1, '```\n/me```'):
|
|
|
|
db = load()
|
|
|
|
return 0
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
db = load()
|
|
|
|
user = db[nick]
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
ch = user.channel
|
|
|
|
user = db[nick]
|
|
|
|
if not user.channel:
|
|
|
|
ch = user.channel
|
|
|
|
ch = "Не задан."
|
|
|
|
if not user.channel:
|
|
|
|
|
|
|
|
ch = "Не задан."
|
|
|
|
|
|
|
|
|
|
|
|
bot.reply_to(message, f"""Заданный канал: {telebot.formatting.hcode(ch)}
|
|
|
|
bot.reply_to(message, f"""Заданный канал: {telebot.formatting.hcode(ch)}
|
|
|
|
|
|
|
|
|
|
|
|
Ваш ник: {telebot.formatting.hcode(nick)}
|
|
|
|
Ваш ник: {telebot.formatting.hcode(nick)}
|
|
|
|
Ваша аватарка: {telebot.formatting.hcode(user.avatar)}
|
|
|
|
Ваша аватарка: {telebot.formatting.hcode(user.avatar)}
|
|
|
@ -263,10 +268,14 @@ def catch_all_messages(message):
|
|
|
|
bot.reply_to(message, "Не существует данного пользователя.")
|
|
|
|
bot.reply_to(message, "Не существует данного пользователя.")
|
|
|
|
elif user.channel != None:
|
|
|
|
elif user.channel != None:
|
|
|
|
channel = user.channel
|
|
|
|
channel = user.channel
|
|
|
|
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
# Проверяем существование пользователя
|
|
|
|
|
|
|
|
if channel not in db:
|
|
|
|
|
|
|
|
bot.reply_to(message, "Не существует данного пользователя.")
|
|
|
|
|
|
|
|
return 0
|
|
|
|
# Проверяем ключи
|
|
|
|
# Проверяем ключи
|
|
|
|
if not key_valid(bot, message, channel):
|
|
|
|
if not key_valid(bot, message, channel):
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if message.chat.id not in db[channel].blocks:
|
|
|
|
if message.chat.id not in db[channel].blocks:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -299,7 +308,10 @@ def catch_all_messages(message):
|
|
|
|
caption = ""
|
|
|
|
caption = ""
|
|
|
|
bot.send_video(db[channel].id, vid_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}", parse_mode="HTML")
|
|
|
|
bot.send_video(db[channel].id, vid_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}", parse_mode="HTML")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.send_message(db[channel].id, f"{telebot.formatting.hcode(':'+nick) + avatar}\n" + message.text, parse_mode="HTML")
|
|
|
|
try:
|
|
|
|
|
|
|
|
bot.send_message(db[channel].id, f"{telebot.formatting.hcode(':'+nick) + avatar}\n" + message.text, parse_mode="HTML")
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
catch_error(bot, message, 'spec_symb')
|
|
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(bot, message)
|
|
|
|
catch_error(bot, message)
|
|
|
|