Python Telegram Bots made easy
Project description
Pytbo is a module aimed at simplifying the creation of Telegram Bots using Python.
A minimum familiarity with Telegram Bots is required to use this library. Please take a look at the introduction and the FAQ before starting.
Getting Started
To start working with Pytbo, you must have a Bot token. If you don’t know what we’re talking about, read how to create your first bot with BotFather.
This is a simple _echo_ bot done with Pytbo that looks for updates every 5 seconds.
import pytbo
import time
# Bot Token received from Telegram
BOT_TOKEN = "MY_BOT_TOKEN"
# Polling interval in seconds
INTERVAL = 5
# Create bot object
bot = pytbo.BareBot(BOT_TOKEN)
# Print bot information
print("Bot ID......: %s" % (bot.id))
print("Bot username: %s" % (bot.username))
# Initialize offset
offset = 0
# Infinite polling loop
while True:
# Look for updates
updates = bot.getUpdates(offset)
# Handle them
for u in updates:
if u.message:
if u.message.text:
# If the update contains a message
# that contains text, we reply to the
# sender with the same text.
bot.sendMessage(
u.message.chat.id,
u.message.text,
reply_to_message_id=u.message.message_id
)
# Update offset to avoid receiving
# the same update again
offset = u.update_id + 1
# Sleep
time.sleep(INTERVAL)
Installation
To install Pytbo, simply:
$ pip install pytbo
Documentation
A proper documentation is not yet available, but it will be. However, useful methods and classes are documented inside the source code.
Don’t be afraid to have a look inside, sometimes is the best way to learn.
How to Contribute
Fork this repository on GitHub to start making your changes to the master branch (or branch off of it).
Send a pull request.
Aknowledgements
Thanks to Kenneth Reitz and to all the other developers of the requests module, which is used inside Pytbo and also as a blueprint for this repository and documentation layout.
Release History
0.1.0 (2016-04-23)
BareBot class that wraps Telegram Bot APIs methods
Types classes that wraps Telegram Bot APIs types
0.0.1 (2016-04-14)
Conception
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytbo-0.1.0.tar.gz
.
File metadata
- Download URL: pytbo-0.1.0.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25ae2d68c36693584e3bb41e88487503409940142f650656a2295681880cd2e2 |
|
MD5 | 4f3834606e23c390ad49d56bffe7f8be |
|
BLAKE2b-256 | 9473313b5533f8da9f7c6cefe2dfb33736aae37448990007e676b4dd53797396 |
File details
Details for the file pytbo-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytbo-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 199f418b686d921fea9ea1e6e5b10b419f4160eaf899cdad573aa04533d8d5b3 |
|
MD5 | bb6a8d27c5b01ff738b68c375aa32175 |
|
BLAKE2b-256 | d0b4fab579ee03191a7942440d9387b392a0bcb7835366ac4f3b2406dcb8b44f |