39 lines
762 B
Python
39 lines
762 B
Python
|
import telebot
|
||
|
|
||
|
### 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, "None")
|
||
|
|
||
|
|
||
|
### MAIN ###
|
||
|
from api import *
|
||
|
|
||
|
|
||
|
@bot.message_handler(func=lambda message: True)
|
||
|
def echo_message(message):
|
||
|
bot.send_chat_action(message.chat.id, "typing", 30)
|
||
|
bot.reply_to(message, gen(message.text, message.chat.id))
|
||
|
|
||
|
|
||
|
############
|
||
|
|
||
|
bot.infinity_polling()
|