A simple and convenient library for creating Telegram bots.
Project description
Extergram v0.6.0 — Asynchronous Telegram Bot Framework
Disclaimer: This project is an independent open-source library and is not affiliated with, associated with, authorized by, endorsed by, or in any way officially connected with Telegram FZ-LLC or any of its subsidiaries or its affiliates.
Extergram is a simple, modern, and fully asynchronous library for creating Telegram bots in Python.
Quick Start
Installation
pip install extergram
Complete Example (main.py)
import asyncio import datetime from extergram import Bot, ButtonsDesign, Message, CallbackQuery, errors from extergram.api_types import BotCommand from extergram.ext import CommandHandler, CallbackQueryHandler
Initialize the bot with your token
bot = Bot('YOUR_BOT_TOKEN')
Create an inline keyboard with a new URL button
main_menu = ButtonsDesign().add_row( ButtonsDesign.create_button("Show time", "show_time"), ButtonsDesign.create_button("About", "about") ).add_row( ButtonsDesign.create_url_button("GitHub", "https://github.com/AAVTIBI1/extergram"), ButtonsDesign.create_button("Delete", "delete") )
async def start(bot_instance: Bot, message: Message): user_name = message.from_user.first_name await bot_instance.send_message( chat_id=message.chat.id, text=f"Hello, {user_name}! I am running on Extergram v0.6.0.", reply_markup=main_menu )
async def handle_callbacks(bot_instance: Bot, callback: CallbackQuery): await bot_instance.answer_callback_query(callback.id)
if callback.data == 'show_time':
now = datetime.datetime.now().strftime("%H:%M:%S")
await bot_instance.edit_message_text(
chat_id=callback.message.chat.id,
message_id=callback.message.message_id,
text=f"The current time is: {now}",
reply_markup=main_menu
)
elif callback.data == 'about':
await bot_instance.edit_message_text(
chat_id=callback.message.chat.id,
message_id=callback.message.message_id,
text="Extergram is a simple and modern async library for Telegram bots.",
reply_markup=main_menu
)
elif callback.data == 'delete':
try:
await bot_instance.delete_message(callback.message.chat.id, callback.message.message_id)
except errors.BadRequestError:
await bot_instance.answer_callback_query(callback.id, "Error: Message is too old to delete.", show_alert=True)
async def main(): bot.add_handler(CommandHandler("start", start)) bot.add_handler(CallbackQueryHandler(handle_callbacks))
print("Bot is starting...")
await bot.polling()
if name == 'main': try: asyncio.run(main()) except KeyboardInterrupt: print("Bot stopped.")
Features & Core Concepts
- Fully Async: High-performance non-blocking operations using
httpx. - Handler System: Manage updates with
CommandHandler,MessageHandler, andCallbackQueryHandler. - Type Hinting: Comprehensive
api_typesfor better IDE support and code clarity. - Error Handling:
errors.NetworkError: Connection issues.errors.BadRequestError: Invalid API requests.errors.ForbiddenError: Bot blocked by user.errors.UnauthorizedError: Invalid token.
Local Documentation
You can access the full documentation directly from your terminal:
from extergram import Docs Docs.print_docs()
License
MIT License. Copyright (c) 2024-2025.
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
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
File details
Details for the file extergram-0.6.0.post1.tar.gz.
File metadata
- Download URL: extergram-0.6.0.post1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6597e8f0351538ebc0107d38c3aed5f2dff63e87c79df7b06c35ed2de8680551
|
|
| MD5 |
210c17546339a72ca904977bb6c269eb
|
|
| BLAKE2b-256 |
b094b0e1e6d1bd188444a388be772da891458960b61c3bfe47b996936f3ea14f
|
File details
Details for the file extergram-0.6.0.post1-py3-none-any.whl.
File metadata
- Download URL: extergram-0.6.0.post1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9009b51a1ef7018cb7f422f6847e23928d04a6dce9f718f27514dc1975f0ba42
|
|
| MD5 |
3ce444f9302fe7f4e5ab2c13d8021ff3
|
|
| BLAKE2b-256 |
b0e0c24c540d4e79112f8244e885551055086654fc219ca630a992834536b259
|