|
|
@ -1,156 +1,36 @@
|
|
|
|
import telebot
|
|
|
|
import telebot
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
|
|
|
|
from icecream import ic
|
|
|
|
|
|
|
|
|
|
|
|
########### Работа с БД ##########
|
|
|
|
########### Функции ##############
|
|
|
|
|
|
|
|
from func import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
########### Работа с БД ##########
|
|
|
|
from db import *
|
|
|
|
from db import *
|
|
|
|
raw_db = read_db()
|
|
|
|
raw_db = read_db()
|
|
|
|
|
|
|
|
|
|
|
|
######### Загрузка БД ############
|
|
|
|
###### Класс пользователя ########
|
|
|
|
|
|
|
|
from user import *
|
|
|
|
# raw_db = {
|
|
|
|
# user.id = 123
|
|
|
|
# "Anon": {"id": 2045634, pkey: "fuD2d", channel: "AnotherUser", avatar: "♿️", blocks: [5375652, 436432], keys: {AnotherUser: "dDH73s"}},
|
|
|
|
# user.pkey = "fd35s"
|
|
|
|
# "2045634": "Anon"
|
|
|
|
# user.channel = "anotheruser"
|
|
|
|
# }
|
|
|
|
# user.avatar = "♿️"
|
|
|
|
# Первая строка - информация о пользователе (айди, канал, блокнутые пользователи)
|
|
|
|
# user.blocks = [124235]
|
|
|
|
# Вторая строчка - для отправки сообщения и блокировки
|
|
|
|
# user.keys = {"anotheruser": "re543"}
|
|
|
|
# keys - ключи , pkey - личный ключ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_num(str):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
int(str)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Класс пользователя
|
|
|
|
|
|
|
|
class user_:
|
|
|
|
|
|
|
|
def __init__(self, id, pkey, channel = None, avatar = "♿️", blocks = [], keys = {}):
|
|
|
|
|
|
|
|
self.id = id
|
|
|
|
|
|
|
|
self.channel = channel
|
|
|
|
|
|
|
|
self.avatar = avatar
|
|
|
|
|
|
|
|
self.blocks = blocks
|
|
|
|
|
|
|
|
self.pkey = pkey
|
|
|
|
|
|
|
|
self.keys = keys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Загружаем в формат
|
|
|
|
|
|
|
|
# db = {
|
|
|
|
|
|
|
|
# "Anon": user.*,
|
|
|
|
|
|
|
|
# "2045634": "Anon"
|
|
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Загружаем
|
|
|
|
|
|
|
|
def load():
|
|
|
|
|
|
|
|
raw_db = read_db()
|
|
|
|
|
|
|
|
db = {}
|
|
|
|
|
|
|
|
for i in raw_db:
|
|
|
|
|
|
|
|
if is_num(i) == True:
|
|
|
|
|
|
|
|
db[i] = raw_db[i]
|
|
|
|
|
|
|
|
elif "token" == i:
|
|
|
|
|
|
|
|
db["token"] = raw_db["token"]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
id, pkey, channel, avatar, blocks, keys = raw_db[i]["id"], raw_db[i]["pkey"], raw_db[i]["channel"], raw_db[i]["avatar"], raw_db[i]["blocks"], raw_db[i]["keys"],
|
|
|
|
|
|
|
|
user = user_(id, pkey, channel, avatar, blocks, keys)
|
|
|
|
|
|
|
|
db[i] = user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Сохраняем
|
|
|
|
|
|
|
|
def save(db):
|
|
|
|
|
|
|
|
raw_db = {}
|
|
|
|
|
|
|
|
for i in db:
|
|
|
|
|
|
|
|
if is_num(i) == True:
|
|
|
|
|
|
|
|
raw_db[i] = db[i]
|
|
|
|
|
|
|
|
elif "token" == i:
|
|
|
|
|
|
|
|
raw_db["token"] = db["token"]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raw_db[i] = {"id": db[i].id, "pkey": db[i].pkey, "channel": db[i].channel, "avatar": db[i].avatar, "blocks": db[i].blocks, "keys": db[i].keys}
|
|
|
|
|
|
|
|
write_db(raw_db)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
####### Работа с хэшем ###########
|
|
|
|
####### Работа с хэшем ###########
|
|
|
|
|
|
|
|
|
|
|
|
from hash import hash
|
|
|
|
from hash import hash
|
|
|
|
from random import randint
|
|
|
|
from random import randint
|
|
|
|
|
|
|
|
|
|
|
|
##### Инициализация токена #######
|
|
|
|
##### Инициализация токена #######
|
|
|
|
|
|
|
|
|
|
|
|
bot = telebot.TeleBot(raw_db['token'])
|
|
|
|
bot = telebot.TeleBot(raw_db['token'])
|
|
|
|
|
|
|
|
|
|
|
|
########## Ловим ошибки ##########
|
|
|
|
########## Ловим ошибки ##########
|
|
|
|
|
|
|
|
from catch_err import *
|
|
|
|
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
import traceback
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from io import StringIO # For catch log to variable
|
|
|
|
############## MAIN ##############
|
|
|
|
|
|
|
|
|
|
|
|
# Basic init
|
|
|
|
|
|
|
|
global log_stream
|
|
|
|
|
|
|
|
log_stream = StringIO()
|
|
|
|
|
|
|
|
logging.basicConfig(stream=log_stream)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def catch_error(message, err_type = None):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
if not err_type:
|
|
|
|
|
|
|
|
global log_stream
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logging.error(traceback.format_exc()) # Log error
|
|
|
|
|
|
|
|
err = log_stream.getvalue() # Error to variable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bot.reply_to(message, "Critical error:\n\n" + telebot.formatting.hcode(err), parse_mode='HTML')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log_stream.truncate(0) # Clear
|
|
|
|
|
|
|
|
log_stream.seek(0) # Clear
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### Небольшие функции ####
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_auth(message):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
if str(message.chat.id) in db:
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
bot.reply_to(message,"Извините, но Вы не авторизованы.\n\n/reg ник")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
catch_error(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Регулярные выражения
|
|
|
|
|
|
|
|
from re import search, match, sub, compile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def nick_ok(message, nick):
|
|
|
|
|
|
|
|
if len(nick) > 30:
|
|
|
|
|
|
|
|
bot.reply_to(message,"Слишком длинный ник, попробуйте короче.")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
if is_num(nick):
|
|
|
|
|
|
|
|
bot.reply_to(message,"Ник должен содержать хоть 1 букву, попробуйте ещё раз.")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
en = True
|
|
|
|
|
|
|
|
ru = True
|
|
|
|
|
|
|
|
# Если только английский
|
|
|
|
|
|
|
|
regex = compile('[^a-zA-Z0-9]')
|
|
|
|
|
|
|
|
check = regex.sub('', nick)
|
|
|
|
|
|
|
|
if check != nick:
|
|
|
|
|
|
|
|
en = False
|
|
|
|
|
|
|
|
# Если только русский
|
|
|
|
|
|
|
|
regex = compile('[^а-яА-ЯЁё0-9]')
|
|
|
|
|
|
|
|
check = regex.sub('', nick)
|
|
|
|
|
|
|
|
if check != nick:
|
|
|
|
|
|
|
|
ru = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if en == False and ru == False:
|
|
|
|
|
|
|
|
bot.reply_to(message,"Нельзя смешивать алфавиты и ставить спец.-символы, попробуйте ещё раз")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############## MAIN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['start', 'help'])
|
|
|
|
@bot.message_handler(commands=['start', 'help'])
|
|
|
|
def start(message):
|
|
|
|
def start(message):
|
|
|
@ -173,7 +53,7 @@ def reg(message):
|
|
|
|
if len(message.text.split()) == 2:
|
|
|
|
if len(message.text.split()) == 2:
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
# Проверка ника
|
|
|
|
# Проверка ника
|
|
|
|
if not nick_ok(message, nick):
|
|
|
|
if not nick_ok(bot, message, nick):
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
if nick in db:
|
|
|
|
if nick in db:
|
|
|
|
bot.reply_to(message, "Данный пользователь уже зарегистрирован.")
|
|
|
|
bot.reply_to(message, "Данный пользователь уже зарегистрирован.")
|
|
|
@ -189,12 +69,12 @@ def reg(message):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message, "Вы ввели не 2 аргумента, нужно: /reg ЛюбойНикнейм")
|
|
|
|
bot.reply_to(message, "Вы ввели не 2 аргумента, нужно: /reg ЛюбойНикнейм")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(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(message):
|
|
|
|
if is_auth(bot, message):
|
|
|
|
db = load()
|
|
|
|
db = load()
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
user = db[nick]
|
|
|
|
user = db[nick]
|
|
|
@ -212,12 +92,12 @@ def b(message):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message, "Данного пользователя не существует.")
|
|
|
|
bot.reply_to(message, "Данного пользователя не существует.")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(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(message):
|
|
|
|
if is_auth(bot, message):
|
|
|
|
db = load()
|
|
|
|
db = load()
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
user = db[nick]
|
|
|
|
user = db[nick]
|
|
|
@ -232,12 +112,12 @@ def u(message):
|
|
|
|
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")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(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(message):
|
|
|
|
if is_auth(bot, message):
|
|
|
|
db = load()
|
|
|
|
db = load()
|
|
|
|
new_nick = message.text.split()[1]
|
|
|
|
new_nick = message.text.split()[1]
|
|
|
|
# Проверка ника
|
|
|
|
# Проверка ника
|
|
|
@ -257,12 +137,12 @@ def nick(message):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message,"Данный ник уже занят")
|
|
|
|
bot.reply_to(message,"Данный ник уже занят")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(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(message):
|
|
|
|
if is_auth(bot, message):
|
|
|
|
db = load()
|
|
|
|
db = load()
|
|
|
|
if not len(message.text.split()) > 1:
|
|
|
|
if not len(message.text.split()) > 1:
|
|
|
|
bot.reply_to(message,"Укажите аватарку")
|
|
|
|
bot.reply_to(message,"Укажите аватарку")
|
|
|
@ -276,10 +156,9 @@ def av(message):
|
|
|
|
save(db)
|
|
|
|
save(db)
|
|
|
|
bot.reply_to(message,"Новая аватарка успешно установлена")
|
|
|
|
bot.reply_to(message,"Новая аватарка успешно установлена")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############# WORK WITH KEY ########
|
|
|
|
######### Работа с ключом ########
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['key'])
|
|
|
|
@bot.message_handler(commands=['key'])
|
|
|
|
def key(message):
|
|
|
|
def key(message):
|
|
|
@ -294,7 +173,7 @@ def key(message):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message,"/key ник")
|
|
|
|
bot.reply_to(message,"/key ник")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['ver'])
|
|
|
|
@bot.message_handler(commands=['ver'])
|
|
|
|
def ver(message):
|
|
|
|
def ver(message):
|
|
|
@ -316,12 +195,12 @@ def ver(message):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message,"/ver ник ключ")
|
|
|
|
bot.reply_to(message,"/ver ник ключ")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(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(message):
|
|
|
|
if is_auth(bot, message):
|
|
|
|
db = load()
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
|
|
|
|
key = hash(randint(74287, 5747962))
|
|
|
|
key = hash(randint(74287, 5747962))
|
|
|
@ -336,50 +215,15 @@ def key_res(message):
|
|
|
|
Старый ключ: {telebot.formatting.hcode(old_key)}
|
|
|
|
Старый ключ: {telebot.formatting.hcode(old_key)}
|
|
|
|
Новый ключ: {telebot.formatting.hcode(key)}""",parse_mode="HTML")
|
|
|
|
Новый ключ: {telebot.formatting.hcode(key)}""",parse_mode="HTML")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
# Проверяем совпадение ключей при отправке сообщений
|
|
|
|
|
|
|
|
def key_valid(message, channel):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
our_nick = db[str(message.chat.id)]
|
|
|
|
|
|
|
|
user = db[our_nick]
|
|
|
|
|
|
|
|
# Добавляем ключ если его нету в нашей БД
|
|
|
|
|
|
|
|
if channel not in user.keys:
|
|
|
|
|
|
|
|
user.keys[channel] = db[channel].pkey
|
|
|
|
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
our_key = user.keys[channel]
|
|
|
|
|
|
|
|
print(channel)
|
|
|
|
|
|
|
|
dest_key = db[channel].pkey
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if our_key == dest_key:
|
|
|
|
|
|
|
|
print("Valid: ", channel)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print("Not valid: ", channel)
|
|
|
|
|
|
|
|
use.keys[channel] = dest_key
|
|
|
|
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bot.reply_to(message, f"""⚠️ Публичные ключи не совпадают ⚠️
|
|
|
|
|
|
|
|
Ожидаемый ключ: {telebot.formatting.hcode(our_key)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Отправка сообщения отклонена.
|
|
|
|
|
|
|
|
Если вы уверены - повторите отправку.
|
|
|
|
|
|
|
|
""", parse_mode="HTML")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
catch_error(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
####################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##################################
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(commands=['me'])
|
|
|
|
@bot.message_handler(commands=['me'])
|
|
|
|
def me(message):
|
|
|
|
def me(message):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if is_auth(message):
|
|
|
|
if is_auth(bot, message):
|
|
|
|
db = load()
|
|
|
|
db = load()
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
user = db[nick]
|
|
|
|
user = db[nick]
|
|
|
@ -393,9 +237,10 @@ def me(message):
|
|
|
|
Ваша аватарка: {telebot.formatting.hcode(user.avatar)}
|
|
|
|
Ваша аватарка: {telebot.formatting.hcode(user.avatar)}
|
|
|
|
Ваш публичный ключ: {telebot.formatting.hcode(user.pkey)}""",parse_mode="HTML")
|
|
|
|
Ваш публичный ключ: {telebot.formatting.hcode(user.pkey)}""",parse_mode="HTML")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###### Передача сообщений ########
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(func=lambda message: True, content_types=['photo','text', 'document', 'voice', 'video'])
|
|
|
|
@bot.message_handler(func=lambda message: True, content_types=['photo','text', 'document', 'voice', 'video'])
|
|
|
|
def catch_all_messages(message):
|
|
|
|
def catch_all_messages(message):
|
|
|
@ -408,7 +253,7 @@ def catch_all_messages(message):
|
|
|
|
channel = message.text[1:]
|
|
|
|
channel = message.text[1:]
|
|
|
|
if channel in db:
|
|
|
|
if channel in db:
|
|
|
|
# Проверяем ключи
|
|
|
|
# Проверяем ключи
|
|
|
|
if not key_valid(message, channel):
|
|
|
|
if not key_valid(bot, message, channel):
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
user.channel = channel
|
|
|
|
user.channel = channel
|
|
|
@ -419,7 +264,7 @@ def catch_all_messages(message):
|
|
|
|
elif user.channel != None:
|
|
|
|
elif user.channel != None:
|
|
|
|
channel = user.channel
|
|
|
|
channel = user.channel
|
|
|
|
# Проверяем ключи
|
|
|
|
# Проверяем ключи
|
|
|
|
if not key_valid(message, channel):
|
|
|
|
if not key_valid(bot, message, channel):
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
db = load()
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
|
|
|
@ -457,20 +302,23 @@ def catch_all_messages(message):
|
|
|
|
bot.send_message(db[channel].id, f"{telebot.formatting.hcode(':'+nick) + avatar}\n" + message.text, parse_mode="HTML")
|
|
|
|
bot.send_message(db[channel].id, f"{telebot.formatting.hcode(':'+nick) + avatar}\n" + message.text, parse_mode="HTML")
|
|
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
bot.reply_to(message, "Сообщение не было доставлено.\nВероятно пользователь заблокировал бота.")
|
|
|
|
bot.reply_to(message, "Сообщение не было доставлено.\nВероятно пользователь заблокировал бота.")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message, "Увы, но вас заблокировал данный пользователь.")
|
|
|
|
bot.reply_to(message, "Увы, но вас заблокировал данный пользователь.")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
bot.reply_to(message, f"У вас не указан чат.\nЧтобы подключится к чату напишите: {telebot.formatting.hcode(':Никнейм')} ", parse_mode="HTML")
|
|
|
|
bot.reply_to(message, f"У вас не указан чат.\nЧтобы подключится к чату напишите: {telebot.formatting.hcode(':Никнейм')} ", parse_mode="HTML")
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
catch_error(message)
|
|
|
|
catch_error(bot, message)
|
|
|
|
|
|
|
|
|
|
|
|
#### POLLING ####
|
|
|
|
#### POLLING ####
|
|
|
|
mode = 1
|
|
|
|
from sys import argv
|
|
|
|
# Normal - 0, debug - 1
|
|
|
|
if len(argv) > 1:
|
|
|
|
|
|
|
|
mode = "debug"
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
mode = "normal"
|
|
|
|
|
|
|
|
|
|
|
|
if mode == 0:
|
|
|
|
if mode == "normal":
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
bot.polling()
|
|
|
|
bot.polling()
|
|
|
@ -478,5 +326,6 @@ if mode == 0:
|
|
|
|
exit()
|
|
|
|
exit()
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
elif mode == 1:
|
|
|
|
elif mode == "debug":
|
|
|
|
|
|
|
|
ic("Started debug...")
|
|
|
|
bot.polling()
|
|
|
|
bot.polling()
|
|
|
|