Skip to content

Telepot

telepot - Python framework for Telegram Bot API.

How to install

sudo apt-get install python-pip
sudo pip install telepot

Example

Test the account

>>> import telepot
>>> bot = telepot.Bot('***** PUT YOUR TOKEN HERE *****')
>>> bot.getMe()
{u'username': u'YourBot', u'first_name': u'Your Bot', u'id': 123456789}

An easier way to receive messages

>>> from pprint import pprint
>>> def handle(msg):
...     pprint(msg)
...
>>> bot.message_loop(handle)

Send messages

Enough about receiving messages. Sooner or later, your bot will want to send you messages. You should have discovered your own user ID from above interactions. I will keeping using my fake ID of 999999999. Remember to substitute your own (real) user ID.

>>> bot.sendMessage(999999999, 'Good morning!')

Local Download

Telepot 3532cbf 2016/06/10
Telepot-3532cbf.zip

See also

Favorite site