Skip to content

Instantly share code, notes, and snippets.

@server.route('/' + TOKEN, methods=['POST'])
def getMessage():
bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
return "!", 200
@server.route("/")
def webhook():
bot.remove_webhook()
bot.set_webhook(url='https://<insert heroku app name here>.herokuapp.com/' + TOKEN)
return "!", 200
@bot.message_handler(commands=['start']) # welcome message handler
def send_welcome(message):
bot.reply_to(message, 'Hello! I am bot')
@bot.message_handler(commands=['help']) # help message handler
def send_welcome(message):
bot.reply_to(message, 'Help message')
@bot.message_handler(func=lambda message: True) # makes the bot imitate the user's message
def echo_all(message):