High-performance Telegram API framework for Python.
Project description
Sayagram
High-Performance Telegram API Framework for Python
Sayagram is an elegant, asynchronous, and deeply customizable Python framework for Telegram bots, user clients, and MTProto-powered applications. It gives developers a clean Sayagram API for building scalable Telegram projects with minimal boilerplate.
Why Sayagram?
When building production-grade Telegram applications, you need a framework that stays simple at the surface and powerful underneath.
- Modern Telegram UX: Custom emoji entities, inline keyboard helpers, callback data, and clean message reply tools.
- High-concurrency ready: Built around Python asyncio for responsive bot and user automation workflows.
- Unified app style: Write intuitive
Client,filters, andMessagecode for standard bots and larger Telegram applications. - Direct escape hatch: Use
app.rawwhen you need precise low-level control. - One install command: Publish, install, and import as Sayagram.
Installation
Install Sayagram from PyPI:
pip install -U sayagram
Requires Python 3.10 or higher.
Quick Start
The Standard Bot
Build a responsive Telegram bot with a small, readable Sayagram app.
from sayagram import Client, filters
app = Client(
"my_bot",
bot_token="your_bot_token",
)
@app.on_message(filters.command("start") & filters.private)
async def hello(client, message):
await message.reply_text("Hello from Sayagram!")
if __name__ == "__main__":
app.run()
Smart Keyboards and Custom Emojis
Sayagram includes small UI helpers and custom emoji entity builders for richer Telegram messages.
from sayagram import (
Client,
InlineKeyboardButton,
InlineKeyboardMarkup,
custom_emoji,
filters,
render,
)
app = Client("menu_bot", bot_token="your_bot_token")
@app.on_message(filters.command("menu"))
async def send_menu(client, message):
keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"Confirm Action",
callback_data="confirm",
)
]
]
)
text, entities = render(
[
"Please confirm your action ",
custom_emoji("5368324170671202286", "\U0001F44D"),
]
)
await message.reply_text(text, entities=entities, reply_markup=keyboard)
Direct Async Usage
import asyncio
from sayagram import Sayagram
async def main() -> None:
async with Sayagram(api_id=12345, api_hash="api_hash") as app:
await app.send_message("me", "Hello from Sayagram")
asyncio.run(main())
Common Framework API
Sayagram gives you a common framework API for everyday Telegram work:
Client(...): create one Sayagram app for bots or advanced clients.filters.command(...),filters.private,filters.group: route updates with readable async filters.Message.reply_text(...): reply from a normalized message object.send_message(...): send text with entities, keyboards, and extra options.send_custom_emoji_message(...): send custom emoji entity markup safely.edit_message(...): edit text without changing app style.delete_message(...): remove messages with one call.download_media(...): download files through the selected engine.InlineKeyboardMarkupandInlineKeyboardButton: build inline keyboards directly from Sayagram.app.raw: access the selected low-level engine when you need advanced Telegram control.
Environment Configuration
Sayagram.from_env() reads these variables:
SAYAGRAM_BACKEND:auto,bot,user, ormtproto.SAYAGRAM_BOT_TOKENorBOT_TOKEN.SAYAGRAM_API_IDorAPI_ID.SAYAGRAM_API_HASHorAPI_HASH.SAYAGRAM_SESSION.
When backend="auto", Sayagram chooses the right engine from your credentials.
Contributing and Support
Sayagram is actively developed and welcomes feedback, bug reports, and feature ideas.
- Issue tracker: GitHub Issues
- Source code: GitHub Repository
- Package: PyPI Project
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
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 sayagram-0.4.3.tar.gz.
File metadata
- Download URL: sayagram-0.4.3.tar.gz
- Upload date:
- Size: 855.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e1153db7b680e0e2e6aa53ed922b7079123240b6668d2aeb2cb9aff20a92150
|
|
| MD5 |
f1e3e18771d3fdacfc814c129c2bdff1
|
|
| BLAKE2b-256 |
46ca9dd2793c9c7ebb58f008be95ad0c16e4ace2da3bd90b78c4428dcf9b5300
|
File details
Details for the file sayagram-0.4.3-py3-none-any.whl.
File metadata
- Download URL: sayagram-0.4.3-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feba9e074fd850466363661b9f2d9598f6c67f68317bb4db9eb30389bfba5925
|
|
| MD5 |
0c5bab7b10345163a628f496e95f0144
|
|
| BLAKE2b-256 |
4726e9f1eba2dc738ce62a3f49bd12a1595b9d0754dae3adbe0b1d3a516eccb2
|