Skip to main content

Modern asynchronous Telegram MTProto framework.

Project description

DryGram Logo

DryGram

Modern, fully asynchronous, production-ready Telegram MTProto v2.0 client framework built from scratch in Python.

Python Version License Badge Latest Release Downloads Documentation Badge GitHub Stars GitHub Issues Build Status PyPI Version


Introduction

DryGram is a production-grade, highly-optimized, fully asynchronous Telegram MTProto client framework built from scratch in Python 3.13+. It implements the secure MTProto v2.0 protocol and integrates the latest Telegram features natively.

Designed with architectural originality at its core, DryGram does NOT duplicate or copy Pyrogram, Telethon, or other existing wrappers. It features a decoupled structure, pluggable session stores, extensible middleware chains, and a robust update dispatcher system to achieve maximum performance and scalability.


Features

Feature Description
Authentication Support for Bot authorization, User authorization, 2FA password verification, and QR Login flows.
Sessions Pluggable, highly-concurrent database storage backends: SQLite, MongoDB, Redis, and PostgreSQL.
Stories High-level APIs for publishing stories, reacting to them, archiving stories, and adjusting story privacy.
Business Full support for Telegram Business greeting/away responses, custom business links, and short reply templates.
Premium Operations for Telegram Star payments, upgradeable gifts, collectibles, and custom Premium Emoji Statuses.
Media Chunked uploads, high-speed concurrent downloads, and representations for Photos, Videos, Documents, Audios, and VoiceNotes.
Text Formatting Built-in, high-speed parsers for Markdown and HTML messages.
Keyboards Declarative markup interfaces for Reply and Inline keyboards, callback button handlers, and interactive menus.
Plugin System & Middleware Extensible middleware pipelines, priority-based command watchers, and modular update routing.
Raw MTProto & AsyncIO Direct invocation of raw TL schema functions via async loops.

Installation

Stable Release

Install the core package via PyPI:

pip install drygram

Installation with Optional Extras

For external voice and video calling support:

pip install "drygram[calls]"

Alternative Package Managers

Using uv:

uv pip install drygram

Using Poetry:

poetry add drygram

Installation from Source

To install the latest development code from GitHub:

git clone https://github.com/TG-BOTSNETWORK/drygram.git
cd drygram
pip install -e .

To install development and testing dependencies:

pip install -e .[dev]

Quick Start

The following is a complete runnable bot that responds to /start messages:

import asyncio
from drygram import DryClient, Gates, Message

# Initialize the client
app = DryClient("bot_session", api_id=12345, api_hash="abcdef", bot_token="YOUR_BOT_TOKEN")

# Register an update observer for /start text commands
@app.observe(Gates.text("/start"))
async def start_handler(msg: Message):
    await app.echo(msg, "Hello! I am a DryGram bot.")

async def main():
    async with app:
        print("Bot started. Press Ctrl+C to stop.")
        await app.idle()

if __name__ == "__main__":
    asyncio.run(main())

Session String Example

You can export and import session strings to run the client without persistent session files on disk:

import asyncio
from drygram import DryClient

async def main():
    async with DryClient("session_name", api_id=12345, api_hash="abc") as app:
        # Export the active authenticated session to an encoded string
        session_str = await app.export_session()
        print("Session String:", session_str)

        # Import the session string into another instance
        await app.import_session(session_str)

if __name__ == "__main__":
    asyncio.run(main())

Project Structure

drygram/
├── drygram/           # Primary package source code
├── docs/              # Detailed guides and manuals
├── examples/          # Complete client usage examples
├── tests/             # Comprehensive testing suite
├── pyproject.toml     # Project metadata and configurations
└── setup.py           # Legacy installer script

Documentation

The full documentation is available under the docs/ directory, containing tutorials and details about the architecture. You can also build it locally using MkDocs:

pip install mkdocs-material
mkdocs serve

Supported Platforms

  • Windows: x86, x64, ARM64, and WSL.
  • Linux: Ubuntu, Debian, Arch Linux, Fedora, CentOS, and Alpine.
  • macOS: Intel and Apple Silicon (M1/M2/M3).
  • Containerization: Full support for Docker and Kubernetes environments.

Optional Voice Support

Voice and video calling functionality are supported through external integrations. Users can utilize third-party WebRTC/calling libraries alongside DryClient for streaming capabilities:

  • py-tgcalls == 2.3.3
  • ntgcalls == 2.2.5

These dependencies can be installed using the optional calls extra group:

pip install "drygram[calls]"

Community


Special Thanks

  • Telegram Team for providing public MTProto documentation and protocol specifications.
  • The Python Open-Source Community for developing the underlying dependencies and testing systems that power modern async development.
  • Contributors and community members helping review code and report issues.

Credits


License

This project is licensed under the GNU General Public License v3.0.

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

drygram-1.0.0.tar.gz (111.6 kB view details)

Uploaded Source

Built Distribution

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

drygram-1.0.0-py3-none-any.whl (106.7 kB view details)

Uploaded Python 3

File details

Details for the file drygram-1.0.0.tar.gz.

File metadata

  • Download URL: drygram-1.0.0.tar.gz
  • Upload date:
  • Size: 111.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for drygram-1.0.0.tar.gz
Algorithm Hash digest
SHA256 25876c05028df76e34f0b4d87dd1ca5ad1c813b950570b607f57b6fbbe31e890
MD5 f957b05000cd16b5d03e98a66948e4fb
BLAKE2b-256 0e66591858f6f7502afde0d3d9c46f698ab7ace57019b7e93cead58c776107c7

See more details on using hashes here.

File details

Details for the file drygram-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: drygram-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 106.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for drygram-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c696463841bb6b4e67c00903cbcef1533256577872947e8152f8c7a48ff8de47
MD5 4ba549006bd43b398d118d1ce561cc59
BLAKE2b-256 686efd0f835a6e8f4e03a5dd1825617f661dc11fc28ba6abeadc8ea79e135804

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