Skip to main content

Abstraction Layer Over Telegram's Bot API and MTProto Chat Potocols

Project description

contributions:Please join
issues:Please use
Python version supported:

TWX is a python interface for the Telegram bot API. It supports making synchronous and asynchronous calls and converts the response into a usable native python object.

Support for the MTProto API is in the works, but considered pre-alpha right now.


For stable:

pip install twx

For dev:

pip install -i twx

Quick Start

from twx.botapi import TelegramBot, ReplyKeyboardMarkup

Setup the bot

bot = TelegramBot('<API TOKEN>')

Send a message to a user
user_id = int(<someuserid>)

result = bot.send_message(user_id, 'test message body').wait()

Get updates sent to the bot
updates = bot.get_updates().wait()
for update in updates:

Use a custom keyboard
keyboard = [
    ['7', '8', '9'],
    ['4', '5', '6'],
    ['1', '2', '3'],
reply_markup = ReplyKeyboardMarkup.create(keyboard)

bot.send_message(user_id, 'please enter a number', reply_markup=reply_markup).wait()

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for twx, version 0.5a5
Filename, size & hash File type Python version Upload date
twx-0.5a5-py3.4.egg (15.7 kB) View hashes Egg 3.4 (10.1 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page