|
|
|
@ -2,44 +2,85 @@ import telebot
|
|
|
|
|
import os
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
global db
|
|
|
|
|
########### Работа с БД ##########
|
|
|
|
|
|
|
|
|
|
########### CREATE DB IF NOT EXIST
|
|
|
|
|
|
|
|
|
|
if not os.path.exists('db.json'):
|
|
|
|
|
db = {"token": "None"}
|
|
|
|
|
js = json.dumps(db, indent=2)
|
|
|
|
|
with open("db.json", "w") as outfile:
|
|
|
|
|
outfile.write(js)
|
|
|
|
|
from db import *
|
|
|
|
|
raw_db = read_db()
|
|
|
|
|
|
|
|
|
|
print('Input token in "None" (db.json)')
|
|
|
|
|
exit()
|
|
|
|
|
######### Загрузка БД ############
|
|
|
|
|
|
|
|
|
|
# db = {
|
|
|
|
|
# "Anon": {"id": 2045634, channel: "AnotherUser", blocks: [5375652, 436432], avatar: "♿️", pkey: "fuD2d", keys: {AnotherUser: "dDH73s"}},
|
|
|
|
|
# 2045634: "Anon"
|
|
|
|
|
#}
|
|
|
|
|
# Невозможно хешировать айди - это всё ломает
|
|
|
|
|
#
|
|
|
|
|
# raw_db = {
|
|
|
|
|
# "Anon": {"id": 2045634, pkey: "fuD2d", channel: "AnotherUser", avatar: "♿️", blocks: [5375652, 436432], keys: {AnotherUser: "dDH73s"}},
|
|
|
|
|
# "2045634": "Anon"
|
|
|
|
|
# }
|
|
|
|
|
# Первая строка - информация о пользователе (айди, канал, блокнутые пользователи)
|
|
|
|
|
# Вторая строчка - для отправки сообщения и блокировки
|
|
|
|
|
# keys - ключи , pkey - личный ключ
|
|
|
|
|
|
|
|
|
|
############WORK WITH DBs##########
|
|
|
|
|
def is_num(str):
|
|
|
|
|
try:
|
|
|
|
|
int(str)
|
|
|
|
|
return True
|
|
|
|
|
except:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
from db import *
|
|
|
|
|
db = read_db()
|
|
|
|
|
# Класс пользователя
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
###### WORK WITH HASHES ##########
|
|
|
|
|
####### Работа с хэшем ###########
|
|
|
|
|
|
|
|
|
|
from hash import hash
|
|
|
|
|
from random import randint
|
|
|
|
|
|
|
|
|
|
################ TOKEN INIT ######
|
|
|
|
|
##### Инициализация токена #######
|
|
|
|
|
|
|
|
|
|
bot = telebot.TeleBot(db['token'])
|
|
|
|
|
bot = telebot.TeleBot(raw_db['token'])
|
|
|
|
|
|
|
|
|
|
##################CATCH ERRORS####
|
|
|
|
|
########## Ловим ошибки ##########
|
|
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
import traceback
|
|
|
|
@ -66,20 +107,52 @@ def catch_error(message, err_type = None):
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
#### Небольшие функции ####
|
|
|
|
|
|
|
|
|
|
def is_auth(message):
|
|
|
|
|
try:
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
if str(message.chat.id) in db:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
bot.reply_to(message,"Извините, но Вы не авторизованы.")
|
|
|
|
|
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'])
|
|
|
|
|
@bot.message_handler(commands=['start', 'help'])
|
|
|
|
|
def start(message):
|
|
|
|
|
bot.reply_to(message, f"""Приветствую, это бот для анонимного общения.
|
|
|
|
|
Главное - выполняет свою функцию без рекламы, без платы и без слежки.
|
|
|
|
@ -88,7 +161,7 @@ def start(message):
|
|
|
|
|
/reg ЛюбойНикнейм
|
|
|
|
|
Установка адресата - { telebot.formatting.hcode(":НикАдресата") }
|
|
|
|
|
|
|
|
|
|
Исходный код: https://gitea.gulyaipole.fun/justuser/just_anonchat
|
|
|
|
|
Исходный код: https://gitea.404.mn/justuser/just_anonchat
|
|
|
|
|
Связь с админом: { telebot.formatting.hcode(":justuser") }
|
|
|
|
|
|
|
|
|
|
Ещё проекты: @just_openbots""", parse_mode="HTML")
|
|
|
|
@ -96,18 +169,22 @@ def start(message):
|
|
|
|
|
@bot.message_handler(commands=['reg'])
|
|
|
|
|
def reg(message):
|
|
|
|
|
try:
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
if len(message.text.split()) == 2:
|
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
|
# Проверка ника
|
|
|
|
|
if not nick_ok(message, nick):
|
|
|
|
|
return 0
|
|
|
|
|
if nick in db:
|
|
|
|
|
bot.reply_to(message, "Данный пользователь уже зарегистрирован.")
|
|
|
|
|
elif str(message.chat.id) in db:
|
|
|
|
|
bot.reply_to(message, "Вы уже зарегистрированы.")
|
|
|
|
|
else:
|
|
|
|
|
db[nick] = {"id": message.chat.id, "channel": None, "blocks": [], "avatar": "♿️", "pkey": hash(randint(74287, 5747962)), "keys": {}}
|
|
|
|
|
user = user_(message.chat.id, hash(randint(74287, 5747962)))
|
|
|
|
|
db[nick] = user
|
|
|
|
|
db[message.chat.id] = nick
|
|
|
|
|
|
|
|
|
|
write_db(db)
|
|
|
|
|
save(db)
|
|
|
|
|
bot.reply_to(message, "Вы зарегистрировались!\nПриятного использования.")
|
|
|
|
|
else:
|
|
|
|
|
bot.reply_to(message, "Вы ввели не 2 аргумента, нужно: /reg ЛюбойНикнейм")
|
|
|
|
@ -118,8 +195,9 @@ def reg(message):
|
|
|
|
|
def b(message):
|
|
|
|
|
try:
|
|
|
|
|
if is_auth(message):
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
|
user = db[nick]
|
|
|
|
|
block = message.text.split()[1]
|
|
|
|
|
|
|
|
|
|
# Block by ":user"
|
|
|
|
@ -127,9 +205,9 @@ def b(message):
|
|
|
|
|
block = block[1:]
|
|
|
|
|
|
|
|
|
|
if block in db:
|
|
|
|
|
if db[block]["id"] not in db[nick]["blocks"]:
|
|
|
|
|
db[nick]["blocks"].append(db[block]["id"])
|
|
|
|
|
write_db(db)
|
|
|
|
|
if db[block].id not in user.blocks:
|
|
|
|
|
user.blocks.append(db[block].id)
|
|
|
|
|
save(db)
|
|
|
|
|
bot.reply_to(message, f"Пользователь {telebot.formatting.hcode(block)} был заблокирован.",parse_mode="HTML")
|
|
|
|
|
else:
|
|
|
|
|
bot.reply_to(message, "Данного пользователя не существует.")
|
|
|
|
@ -140,17 +218,18 @@ def b(message):
|
|
|
|
|
def u(message):
|
|
|
|
|
try:
|
|
|
|
|
if is_auth(message):
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
|
user = db[nick]
|
|
|
|
|
block = message.text.split()[1]
|
|
|
|
|
|
|
|
|
|
# Unblock by ":user"
|
|
|
|
|
if block[0] == ":":
|
|
|
|
|
block = block[1:]
|
|
|
|
|
|
|
|
|
|
if db[block]["id"] in db[nick]["blocks"]:
|
|
|
|
|
db[nick]["blocks"].remove(db[block]["id"])
|
|
|
|
|
write_db(db)
|
|
|
|
|
if db[block].id in user.blocks:
|
|
|
|
|
user.blocks.remove(db[block].id)
|
|
|
|
|
save(db)
|
|
|
|
|
bot.reply_to(message, f"Была снята блокировка с пользователя {telebot.formatting.hcode(block)}",parse_mode="HTML")
|
|
|
|
|
except:
|
|
|
|
|
catch_error(message)
|
|
|
|
@ -159,16 +238,19 @@ def u(message):
|
|
|
|
|
def nick(message):
|
|
|
|
|
try:
|
|
|
|
|
if is_auth(message):
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
new_nick = message.text.split()[1]
|
|
|
|
|
# Проверка ника
|
|
|
|
|
if not nick_ok(message, new_nick):
|
|
|
|
|
return 0
|
|
|
|
|
old_nick = db[str(message.chat.id)]
|
|
|
|
|
|
|
|
|
|
if new_nick not in db:
|
|
|
|
|
db[new_nick] = db[old_nick]
|
|
|
|
|
db[new_nick]["avatar"] = "♿️"
|
|
|
|
|
db[new_nick].avatar = "♿️"
|
|
|
|
|
db[str(message.chat.id)] = new_nick
|
|
|
|
|
del db[old_nick]
|
|
|
|
|
write_db(db)
|
|
|
|
|
save(db)
|
|
|
|
|
bot.reply_to(message,f"Вы успешно сменили ник с {telebot.formatting.hcode(old_nick)} на {telebot.formatting.hcode(new_nick)}",parse_mode="HTML")
|
|
|
|
|
bot.reply_to(message, """Ваша аватарка сброшена до стандартной: ♿️
|
|
|
|
|
Также вы можете сбросить публичный ключ: /key_res""")
|
|
|
|
@ -181,7 +263,7 @@ def nick(message):
|
|
|
|
|
def av(message):
|
|
|
|
|
try:
|
|
|
|
|
if is_auth(message):
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
if not len(message.text.split()) > 1:
|
|
|
|
|
bot.reply_to(message,"Укажите аватарку")
|
|
|
|
|
return 0
|
|
|
|
@ -190,8 +272,8 @@ def av(message):
|
|
|
|
|
bot.reply_to(message,"Слишком большое количество символов для аватарки")
|
|
|
|
|
else:
|
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
|
db[nick]["avatar"] = new_avatar
|
|
|
|
|
write_db(db)
|
|
|
|
|
db[nick].avatar = new_avatar
|
|
|
|
|
save(db)
|
|
|
|
|
bot.reply_to(message,"Новая аватарка успешно установлена")
|
|
|
|
|
except:
|
|
|
|
|
catch_error(message)
|
|
|
|
@ -203,11 +285,11 @@ def av(message):
|
|
|
|
|
def key(message):
|
|
|
|
|
try:
|
|
|
|
|
if len(message.text.split()) == 2:
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
|
if nick[0] == ':':
|
|
|
|
|
nick = nick[1:]
|
|
|
|
|
key = db[nick]["pkey"]
|
|
|
|
|
key = db[nick].pkey
|
|
|
|
|
bot.reply_to(message,f"Ключ пользователя: {telebot.formatting.hcode(key)}", parse_mode="HTML")
|
|
|
|
|
else:
|
|
|
|
|
bot.reply_to(message,"/key ник")
|
|
|
|
@ -218,7 +300,7 @@ def key(message):
|
|
|
|
|
def ver(message):
|
|
|
|
|
try:
|
|
|
|
|
if len(message.text.split()) == 3:
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
nick = message.text.split()[1]
|
|
|
|
|
if nick[0] == ':':
|
|
|
|
|
nick = nick[1:]
|
|
|
|
@ -227,7 +309,7 @@ def ver(message):
|
|
|
|
|
bot.reply_to(message,"Не существует такого пользователя")
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
if key == db[nick]["pkey"]:
|
|
|
|
|
if key == db[nick].pkey:
|
|
|
|
|
bot.reply_to(message,"✅ Ключи совпадают")
|
|
|
|
|
else:
|
|
|
|
|
bot.reply_to(message,"❌ Ключи не совпадают")
|
|
|
|
@ -240,14 +322,14 @@ def ver(message):
|
|
|
|
|
def key_res(message):
|
|
|
|
|
try:
|
|
|
|
|
if is_auth(message):
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
|
|
key = hash(randint(74287, 5747962))
|
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
|
old_key = db[nick]["pkey"]
|
|
|
|
|
old_key = db[nick].pkey
|
|
|
|
|
|
|
|
|
|
db[nick]["pkey"] = key
|
|
|
|
|
write_db(db)
|
|
|
|
|
db[nick].pkey = key
|
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
|
|
bot.reply_to(message,f"""🔑 Ключ успешно сброшен.
|
|
|
|
|
|
|
|
|
@ -259,24 +341,26 @@ def key_res(message):
|
|
|
|
|
# Проверяем совпадение ключей при отправке сообщений
|
|
|
|
|
def key_valid(message, channel):
|
|
|
|
|
try:
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
our_nick = db[str(message.chat.id)]
|
|
|
|
|
user = db[our_nick]
|
|
|
|
|
# Добавляем ключ если его нету в нашей БД
|
|
|
|
|
if channel not in db[our_nick]["keys"]:
|
|
|
|
|
db[our_nick]["keys"][channel] = db[channel]["pkey"]
|
|
|
|
|
write_db(db)
|
|
|
|
|
if channel not in user.keys:
|
|
|
|
|
user.keys[channel] = db[channel].pkey
|
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
|
|
db = read_db()
|
|
|
|
|
our_key = db[our_nick]["keys"][channel]
|
|
|
|
|
dest_key = db[channel]["pkey"]
|
|
|
|
|
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)
|
|
|
|
|
db[our_nick]["keys"][channel] = dest_key
|
|
|
|
|
write_db(db)
|
|
|
|
|
use.keys[channel] = dest_key
|
|
|
|
|
save(db)
|
|
|
|
|
|
|
|
|
|
bot.reply_to(message, f"""⚠️ Публичные ключи не совпадают ⚠️
|
|
|
|
|
Ожидаемый ключ: {telebot.formatting.hcode(our_key)}
|
|
|
|
@ -295,51 +379,51 @@ def key_valid(message, channel):
|
|
|
|
|
@bot.message_handler(commands=['me'])
|
|
|
|
|
def me(message):
|
|
|
|
|
try:
|
|
|
|
|
db = read_db()
|
|
|
|
|
if is_auth(message):
|
|
|
|
|
db = load()
|
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
|
channel = db[nick]["channel"]
|
|
|
|
|
avatar = db[nick]["avatar"]
|
|
|
|
|
pkey = db[nick]["pkey"]
|
|
|
|
|
if not channel:
|
|
|
|
|
channel = "Не задан."
|
|
|
|
|
user = db[nick]
|
|
|
|
|
ch = user.channel
|
|
|
|
|
if not user.channel:
|
|
|
|
|
ch = "Не задан."
|
|
|
|
|
|
|
|
|
|
bot.reply_to(message, f"""Заданный канал: {telebot.formatting.hcode(channel)}
|
|
|
|
|
bot.reply_to(message, f"""Заданный канал: {telebot.formatting.hcode(ch)}
|
|
|
|
|
|
|
|
|
|
Ваш ник: {telebot.formatting.hcode(nick)}
|
|
|
|
|
Ваша аватарка: {telebot.formatting.hcode(avatar)}
|
|
|
|
|
Ваш публичный ключ: {telebot.formatting.hcode(pkey)}""",parse_mode="HTML")
|
|
|
|
|
Ваша аватарка: {telebot.formatting.hcode(user.avatar)}
|
|
|
|
|
Ваш публичный ключ: {telebot.formatting.hcode(user.pkey)}""",parse_mode="HTML")
|
|
|
|
|
except:
|
|
|
|
|
catch_error(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.message_handler(func=lambda message: True, content_types=['photo','text', 'document', 'voice'])
|
|
|
|
|
@bot.message_handler(func=lambda message: True, content_types=['photo','text', 'document', 'voice', 'video'])
|
|
|
|
|
def catch_all_messages(message):
|
|
|
|
|
try:
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
nick = db[str(message.chat.id)]
|
|
|
|
|
avatar = ' ' + db[nick]["avatar"]
|
|
|
|
|
user = db[nick]
|
|
|
|
|
avatar = ' ' + user.avatar
|
|
|
|
|
if message.content_type == "text" and message.text[:1].lower() == ":":
|
|
|
|
|
channel = message.text[1:]
|
|
|
|
|
if channel in db:
|
|
|
|
|
# Проверяем ключи
|
|
|
|
|
if not key_valid(message, channel):
|
|
|
|
|
return 0
|
|
|
|
|
db = read_db()
|
|
|
|
|
|
|
|
|
|
db[nick]["channel"] = channel
|
|
|
|
|
user.channel = channel
|
|
|
|
|
bot.reply_to(message, "Установлен адресат: " + telebot.formatting.hcode(channel), parse_mode="HTML")
|
|
|
|
|
write_db(db)
|
|
|
|
|
save(db)
|
|
|
|
|
else:
|
|
|
|
|
bot.reply_to(message, "Не существует данного пользователя.")
|
|
|
|
|
elif db[nick]["channel"] != None:
|
|
|
|
|
channel = db[nick]["channel"]
|
|
|
|
|
elif user.channel != None:
|
|
|
|
|
channel = user.channel
|
|
|
|
|
# Проверяем ключи
|
|
|
|
|
if not key_valid(message, channel):
|
|
|
|
|
return 0
|
|
|
|
|
db = read_db()
|
|
|
|
|
db = load()
|
|
|
|
|
|
|
|
|
|
if message.chat.id not in db[channel]["blocks"]:
|
|
|
|
|
if message.chat.id not in db[channel].blocks:
|
|
|
|
|
try:
|
|
|
|
|
# Check if image
|
|
|
|
|
if "photo" in message.json:
|
|
|
|
@ -350,7 +434,7 @@ def catch_all_messages(message):
|
|
|
|
|
else:
|
|
|
|
|
caption = ""
|
|
|
|
|
|
|
|
|
|
bot.send_photo(db[channel]["id"], img_id, f"{telebot.formatting.hcode(':'+nick) + avatar}" + caption, parse_mode="HTML")
|
|
|
|
|
bot.send_photo(db[channel].id, img_id, f"{telebot.formatting.hcode(':'+nick) + avatar}" + caption, parse_mode="HTML")
|
|
|
|
|
|
|
|
|
|
elif "document" in message.json:
|
|
|
|
|
doc_id = message.json['document']['file_id']
|
|
|
|
@ -358,14 +442,22 @@ def catch_all_messages(message):
|
|
|
|
|
caption = "\n" + message.json['caption']
|
|
|
|
|
else:
|
|
|
|
|
caption = ""
|
|
|
|
|
bot.send_document(db[channel]["id"], doc_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}" + caption, parse_mode="HTML")
|
|
|
|
|
bot.send_document(db[channel].id, doc_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}" + caption, parse_mode="HTML")
|
|
|
|
|
elif "voice" in message.json:
|
|
|
|
|
voice_id = message.json['voice']['file_id']
|
|
|
|
|
bot.send_document(db[channel]["id"], voice_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}", parse_mode="HTML")
|
|
|
|
|
bot.send_document(db[channel].id, voice_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}", parse_mode="HTML")
|
|
|
|
|
elif "video" in message.json:
|
|
|
|
|
vid_id = message.json['video']['file_id']
|
|
|
|
|
if "caption" in message.json:
|
|
|
|
|
caption = "\n" + message.json['caption']
|
|
|
|
|
else:
|
|
|
|
|
bot.send_message(db[channel]["id"], f"{telebot.formatting.hcode(':'+nick) + avatar}\n" + message.text, parse_mode="HTML")
|
|
|
|
|
caption = ""
|
|
|
|
|
bot.send_video(db[channel].id, vid_id, caption = f"{telebot.formatting.hcode(':'+nick) + avatar}", parse_mode="HTML")
|
|
|
|
|
else:
|
|
|
|
|
bot.send_message(db[channel].id, f"{telebot.formatting.hcode(':'+nick) + avatar}\n" + message.text, parse_mode="HTML")
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
catch_error(message)
|
|
|
|
|
bot.reply_to(message, "Сообщение не было доставлено.\nВероятно пользователь заблокировал бота.")
|
|
|
|
|
else:
|
|
|
|
|
bot.reply_to(message, "Увы, но вас заблокировал данный пользователь.")
|
|
|
|
@ -375,7 +467,7 @@ def catch_all_messages(message):
|
|
|
|
|
catch_error(message)
|
|
|
|
|
|
|
|
|
|
#### POLLING ####
|
|
|
|
|
mode = 0
|
|
|
|
|
mode = 1
|
|
|
|
|
# Normal - 0, debug - 1
|
|
|
|
|
|
|
|
|
|
if mode == 0:
|
|
|
|
|