A simple Python Telegram bot that echoes your input. Uses Flask, setWebhook method, and Google App Engine (optional)
Switch branches/tags
Nothing to show
Clone or download
sooyhwang Merge pull request #5 from mandarinchik/add_token
Merge pull request #1 from mandarinchik/master
Latest commit addf85b Feb 23, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Updated instruction Aug 12, 2015
app.yaml Update app.yaml Oct 13, 2016
bot.py Added more comments Aug 11, 2015
bot_gae.py Update bot_gae.py Oct 13, 2016
requirements.txt Minor edits + Added requirements.txt Aug 11, 2015

README.md

Simple-Echo-Telegram-Bot

A simple Python Telegram bot that echoes your input. Uses Flask microframework, setWebhook method, and Google App Engine (optional)

This example shows you how to set up webhook, and how to receive and send a text message using the python-telegram-bot library. It supports echoing unicode messages (in UTF-8).

Please exchange the TOKEN, the webhook URL, and the HOOK path with your own.

  • The bot.py file is for general purpose.
  • The bot_gae.py file with app.yaml is for Google App Engine. The only difference is the sys.path.append statement at the top. You may need to edit the virtual environment path to match yours.

Tested on Google App Engine (GAE) with virtualenv enabled. I followed the tutorial in this Youtube video to set things up. Basically you set up virtualenv inside the GAE directory, and then append the path to it in every script that runs. (Otherwise you get an error in the import.)

Required

How to use

  • Install the script
  • Edit TOKEN, URL, HOOK in bot.py or bot_gae.py, and GAE_PROJECT_NAME in app.yaml
  • Visit https://URL/set_webhook on your web browser to set up webhook.
  • Start chatting in Telegram and enjoy your echoes! :)

About SSL Certificate

If your server is not getting any messages from Telegram, chances are your SSL certificate installation lacks the "chain" file. If you received an interm (or intermediate) file from the issuer, install it as well. Here's what the SSL directives in the Virtual Host setting should look like (source):

SSLCertificateFile /etc/ssl/crt/public.crt              //Locate Certificate File
SSLCertificateKeyFile /etc/ssl/crt/private.key          //Locate Private Key File
SSLCertificateChainFile /etc/ssl/crt/intermediate.crt   //Locate the Intermediate File