An asynchronous Python Telegram Bot API wrapper
Project description
TgBee
TgBee is an asynchronous Python wrapper for the Telegram Bot API. It provides a simple and intuitive interface for creating Telegram bots using modern Python features.
Features
- Asynchronous API calls using
aiohttp - Easy-to-use decorator-based handler system
- Support for inline keyboards and callback queries
- Plugin system for modular bot development
- FastAPI integration for webhook support
Installation
You can install TgBee using pip:
pip3 install -U TgBee
Example
import asyncio
from TgBee import Client, filters
bot = Client(token="YOUR_BOT_TOKEN")
@bot.on_message(filters.command("start"))
async def start_command(client, message):
reply_markup = {
"inline_keyboard": [
[
{"text": "Button 1", "callback_data": "button1"},
{"text": "Button 2", "callback_data": "button2"}
]
]
}
mention = message.from_user.mention
sent_message = await client.send_message(
chat_id=message.chat.id,
text=f"Welcome {mention} to the bot! Here's a message with some buttons:",
parse_mode="HTML",
reply_markup=reply_markup
)
@bot.on_callback_query()
async def handle_callback(client, callback_query):
callback_query_id = callback_query.id
data = callback_query.data
if data == "button1":
await client.answer_callback_query(callback_query_id=callback_query_id, text="You pressed Button 1!", show_alert=True)
elif data == "button2":
await client.answer_callback_query(callback_query_id=callback_query_id, text="You pressed Button 2!", show_alert=True)
else:
await client.answer_callback_query(callback_query_id=callback_query_id, text="Unknown button pressed", show_alert=True)
async def main():
await bot.run()
if __name__ == "__main__":
asyncio.run(main())
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
tgbee-1.0.5.tar.gz
(12.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
TgBee-1.0.5-py3-none-any.whl
(12.8 kB
view details)
File details
Details for the file tgbee-1.0.5.tar.gz.
File metadata
- Download URL: tgbee-1.0.5.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4277f39ddf60096e608a343be24d07ab6bc9aa8204350e34696df738cc3075f
|
|
| MD5 |
f5f5f64ef2e85eef3b64aa479464fe3b
|
|
| BLAKE2b-256 |
ca985d26b56cc4b6fdf4a2386b1e24cf582ab5c8ede5269fe4b1e66f56a58280
|
File details
Details for the file TgBee-1.0.5-py3-none-any.whl.
File metadata
- Download URL: TgBee-1.0.5-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d29050f27062add682a8931ef5e34ae74a609f21a4209f744675c5dfecce3fd5
|
|
| MD5 |
4aa2ef7dbab1f04544bdf38d7bdd102d
|
|
| BLAKE2b-256 |
e3862ee0a8dbfcd10b8e9ef3934d039017fbb1c54a8c73f652b07eea91a5ee2c
|