This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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): |