Created
April 25, 2018 12:45
-
-
Save TiagoDanin/ef5e9c64ac4d285d925b329cb2e3365c to your computer and use it in GitHub Desktop.
Exemplo de um Echo Bot usando Webhook. LIB: Python-telegram-bot
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
from telegram.ext import CommandHandler, Updater | |
def echo_cmd(bot, update): #/echo text | |
update.message.reply_text(update.message.text) | |
def main(): | |
token = '' | |
#Test used Localtunnel | |
#Run: lt --port 8000 -s tergvffgs | |
url = 'https://tergvffgs.localtunnel.me' | |
url_path = 'secret-path' | |
port = 8000 | |
updater = Updater(token) | |
updater.dispatcher.add_handler(CommandHandler('echo', echo_cmd)) | |
updater.start_webhook( | |
listen='0.0.0.0', | |
port=port, | |
url_path=url_path | |
) | |
updater.bot.set_webhook(url=url + '/' + url_path) | |
print(updater.bot.get_webhook_info()) | |
#updater.start_polling() | |
updater.idle() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment