Modern async Telegram framework for bots, user clients, and MTProto apps.
Project description
Sayagram
High-performance async Telegram framework for Python bots, userbots, and hybrid applications.
Sayagram gives you one framework API, one package name, and one install command. It includes a native Sayagram Bot API engine for dependency-free bot work, plus lazy advanced engines for larger Telegram applications.
Telegram custom emoji support is implemented with official message entities. Sayagram can send custom emoji where Telegram allows it, but it cannot unlock Telegram Premium or bypass Telegram platform limits.
Installation
pip install -U sayagram
Quick Start
from sayagram import Client, filters
app = Client(
"my_bot",
bot_token="your_bot_token",
)
@app.on_message(filters.command("start") & filters.private)
async def start(client, message):
await message.reply_text("Hello from Sayagram!")
app.run()
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())
Custom Emoji
Telegram custom emoji entities must wrap a normal fallback emoji. Sayagram calculates the correct UTF-16 offsets for Bot API and MTProto libraries.
from sayagram import Client, custom_emoji, render
app = Client("emoji-bot", bot_token="123456:BOT_TOKEN")
async def send_approved(chat_id: int) -> None:
text, entities = render(
[
"Approved ",
custom_emoji("5368324170671202286", "\U0001F44D"),
]
)
await app.send_message(chat_id, text, entities=entities)
Compact markup is supported too:
await app.send_custom_emoji_message(
123456789,
"Approved {emoji:5368324170671202286|\U0001F44D}",
)
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.
Backend Access
Sayagram gives you a common framework API for common work:
start()andstop()run()andrun_forever()on_message()withsayagram.filterssend_message()send_custom_emoji_message()edit_message()delete_message()download_media()
For advanced Telegram features, use app.raw and call the selected backend
directly.
Publishing
Build locally:
python -m build
Upload manually when you have a PyPI token:
python -m twine upload dist/*
The repository also includes a GitHub Actions workflow for PyPI Trusted
Publishing. Configure a PyPI trusted publisher for
shnwazdeveloper/sayagram, then create a GitHub release to publish.
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.0.tar.gz.
File metadata
- Download URL: sayagram-0.4.0.tar.gz
- Upload date:
- Size: 904.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
465dda94be1893acc2ca85dd2892707f3e9edd2dbe1e101e194b2db8a0955fee
|
|
| MD5 |
7fa5aa443586faa91923fb674c3d5ae8
|
|
| BLAKE2b-256 |
7b2e19b6eab6a87b1b0b61280cdd8309683250d8d971676609459b5e04f23440
|
File details
Details for the file sayagram-0.4.0-py3-none-any.whl.
File metadata
- Download URL: sayagram-0.4.0-py3-none-any.whl
- Upload date:
- Size: 21.1 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 |
ac79136021b7807497769e9aaf03dc8c727251412d72b8445e7d5f1e58836bea
|
|
| MD5 |
0a8740e8bc87387dd3312a30afc59f7c
|
|
| BLAKE2b-256 |
0c6aee39b54eee9a39ec1ad1e6de529d037470d5f31f05891cada15490a7b848
|