import telebot from telebot import types,util ### LOAD TOKEN ### import json, os 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) print('Input token in "None" (db.json)') exit() with open('db.json', 'r') as openfile: db = json.load(openfile) API_TOKEN = db["token"] bot = telebot.TeleBot(API_TOKEN) ################## @bot.message_handler(commands=['help', 'start']) def send_welcome(message): bot.reply_to(message, """Приветствую! Это бот для верификации аккаунта на сайте ss14top.404.mn __ Инструкция 1. Зарегистрируйтесь на ss14top.404.mn 2. Отправьте сюда свой ник с сайта 3. Ожидайте, скоро вашу запись одобрят! __ Правила 1. Не больше 1 аккаунта 2. Состоять в чате @ss14_chat 3. Не пытаться нарушить правила Бот собирает: ник ТГ, ID, ник на форуме. Ник ТГ и ID никому кроме админа не передаётся ни при каких условиях. """) # LOAD ID global own_id own_id = db["own_id"] ### @bot.message_handler(commands=['a']) def accept(message): if message.chat.id == own_id: id = message.text[3:] bot.send_message(id, "Ваш аккаунт одобрен!") bot.reply_to(message, f"Заявка {telebot.formatting.hcode( str(id) )} одобрена.", parse_mode="HTML") @bot.message_handler(commands=['d']) def deny(message): if message.chat.id == own_id: id = message.text[3:] reason = ' '.join(message.text.split()[2:]) bot.send_message(id, f"Ваша заявка отклонена, причина: \n\n {reason}") bot.reply_to(message, f"Заявка {telebot.formatting.hcode( str(id) )} отклонена.", parse_mode="HTML") @bot.message_handler(func=lambda message: True) def echo_message(message): global own_id bot.send_message(own_id, f"Пользователь: {telebot.util.user_link(message.from_user)} \nTG: {message.from_user.username} \nID: {telebot.formatting.hcode(str(message.chat.id))} \nНик: {message.text}", parse_mode="HTML") bot.reply_to(message, "Ваши данные отправлены на модерацию.\nПодождите, пожалуйста.") # Check for new message on forum from threading import Thread from time import sleep from check_new import * def check_forum(): global own_id while True: check(bot, own_id) sleep(60) th = Thread(target=check_forum) th.start() bot.infinity_polling()