Skip to main content

High-performance Telegram API framework for Python.

Project description

Sayagram

Sayagram

High-Performance Telegram API Framework for Python

PyPI version Python versions License Telegram Support

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, and Message code for standard bots and larger Telegram applications.
  • Direct escape hatch: Use app.raw when 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())

Environment Configuration

Sayagram.from_env() reads these variables:

  • SAYAGRAM_BACKEND: auto, bot, user, or mtproto.
  • SAYAGRAM_BOT_TOKEN or BOT_TOKEN.
  • SAYAGRAM_API_ID or API_ID.
  • SAYAGRAM_API_HASH or API_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.

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

sayagram-0.4.2.tar.gz (855.1 kB view details)

Uploaded Source

Built Distribution

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

sayagram-0.4.2-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file sayagram-0.4.2.tar.gz.

File metadata

  • Download URL: sayagram-0.4.2.tar.gz
  • Upload date:
  • Size: 855.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for sayagram-0.4.2.tar.gz
Algorithm Hash digest
SHA256 5ec63885a0ecc7705d9505844db18677e752fd9d3391a847e782db8d249da866
MD5 11ffbac8a5a679706e53f4dea0a22f8a
BLAKE2b-256 34fe382e07cc51039c858532115f60658786725524dee2feb8162a9de4cb57ec

See more details on using hashes here.

File details

Details for the file sayagram-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: sayagram-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for sayagram-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d0112ec8cd9bd095d1f418a71fc53511b7c576b538906b2be3481ed374327a6
MD5 6c4ec8542bfcf7490db8430a5feff7e0
BLAKE2b-256 bb8718c9cbbe4f0984e3b7ffd8c9fdf0c6a17d503b08bb331ac679a9460979b9

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