Skip to main content

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.

Don't forget to ⭐ the repository on GitHub Stars

PyPI Telegram

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


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.1.11.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

TgBee-1.1.11-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file tgbee-1.1.11.tar.gz.

File metadata

  • Download URL: tgbee-1.1.11.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for tgbee-1.1.11.tar.gz
Algorithm Hash digest
SHA256 84903cadd6e302d7e437e5d372ffa177f55364a08679aec409780bdfb4135ef5
MD5 c3e849012a996c1a7afb3093aebd1648
BLAKE2b-256 935b3b67d5bf3b83f76a4af8e85804bd81929c8e471515ce5caf1ce6ff038ce4

See more details on using hashes here.

File details

Details for the file TgBee-1.1.11-py3-none-any.whl.

File metadata

  • Download URL: TgBee-1.1.11-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for TgBee-1.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 189dcbc2cbc78d9ba212dcb05467e238bd35cbe5e345a2716a3eb1bd4b57766b
MD5 cbaa195af8719cc0cdd96e64b19bc63e
BLAKE2b-256 ec9736100e656215688c31fc85616dad5de030ba1d9b214e49132491c039011e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page