DLGram: a lightweight, stable Telegram MTProto API framework for bots and user clients
Project description
DLGram
A lightweight Telegram MTProto framework for Python bots and user clients.
Built from the Pyrogram/Pyrofork ecosystem, tuned for lower memory usage, safer downloads, and high-traffic bots.
Read the docs · Report issue · Telegram updates
Why DLGram?
DLGram keeps the familiar pyrogram import style while adding practical fixes for real bots:
- Low RAM mode with smart message cache and bounded update queue.
- High traffic stability with reconnect-safe TCP transport handling.
- Safer downloads with cleaner media/CDN session behavior.
- Direct downloads using
no_temp=Truewhen you do not want.tempfiles. - Simple button API with
color="green",colour="red", or oldstyle="blue". - Premium/custom emoji support in message text and inline buttons.
- GitHub Actions build and GitHub Pages documentation.
Install
Install latest from GitHub:
pip install --no-cache-dir --force-reinstall "git+https://github.com/growxupdate/dlgram.git"
Optional speedup:
pip install -U tgcrypto
Termux setup:
pkg update -y && pkg upgrade -y
pkg install -y python git clang make openssl libffi rust
python -m pip install -U pip setuptools wheel
pip install --no-cache-dir --force-reinstall "git+https://github.com/growxupdate/dlgram.git"
Quick bot
from pyrogram import Client, filters, types
API_ID = 12345
API_HASH = "your_api_hash"
BOT_TOKEN = "your_bot_token"
app = Client(
"bot",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
msg_cache=300,
biz_cache=100,
update_queue=1000,
smart_updates=True,
)
@app.on_message(filters.command("start"))
async def start(_, message):
keyboard = types.InlineKeyboardMarkup([
[types.InlineKeyboardButton(
"Play",
callback_data="play",
color="green",
icon_emoji_id="6267032805910254913",
)],
[types.InlineKeyboardButton("Stop", callback_data="stop", color="red")],
])
await message.reply(
'<emoji id="6266764202950530136">💬</emoji> <b>DLGram is working.</b>',
reply_markup=keyboard,
)
@app.on_callback_query()
async def callback(_, query):
await query.answer(f"Clicked: {query.data}", show_alert=True)
app.run()
Button colors and premium emoji
from pyrogram import types
types.InlineKeyboardButton("OK", callback_data="ok", color="green")
types.InlineKeyboardButton("Cancel", callback_data="cancel", colour="red")
types.InlineKeyboardButton("Info", callback_data="info", style="blue")
types.InlineKeyboardButton(
"Heart",
callback_data="heart",
color="green",
icon_emoji_id="6267032805910254913",
)
Supported colors: default, blue, red, green.
Unsupported colors, for example orange, fall back to default and show a warning.
Message custom emoji:
await message.reply('<emoji id="6266764202950530136">💬</emoji> Premium emoji test')
Downloads
path = await message.download()
path = await message.download(file_name="xyz.m4a", no_temp=True)
path = await app.download_message(message, file_name="xyz.m4a", no_temp=True)
Streaming chunks:
async for chunk in app.stream_media(message):
# write/send chunk
pass
Avoid in_memory=True for large files on small VPS/Termux because it can load the whole file into RAM.
Recommended configs
Big public bot:
app = Client(
"bot",
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
msg_cache=300,
biz_cache=100,
update_queue=1000,
smart_updates=True,
)
Download-only session:
dl = Client(
"download",
api_id=API_ID,
api_hash=API_HASH,
session_string=SESSION_STRING,
no_updates=True,
msg_cache=0,
biz_cache=0,
update_queue=0,
)
Documentation
Main docs are published at:
https://growxupdate.github.io/dlgram
The docs page includes search, install commands, examples, download notes, security notes, and attribution.
Security notes
DLGram should not contain owner backdoors, token dumpers, external paste uploads, or hidden environment exfiltration logic. If you find suspicious code, report it in Issues or in the Telegram update channel.
The repository should never commit real API_HASH, BOT_TOKEN, .session, .session-journal, string sessions, MongoDB URI, or private config files.
Attribution
DLGram is based on the Pyrogram/Pyrofork ecosystem and continues to use upstream concepts and LGPL-licensed code, including MTProto/session architecture, generated Telegram raw API types/functions, parsers, storage helpers, handlers, filters, and crypto utilities.
See NOTICE, COPYING, and COPYING.lesser for licensing and attribution details.
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 dlgram-3.0.0.tar.gz.
File metadata
- Download URL: dlgram-3.0.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecac7c14bb4295c8c35d6de601470087c4c1de9a569a4c555585a2b853cf82c5
|
|
| MD5 |
5e0b8fc3eea75ebf1d92925f57cdec99
|
|
| BLAKE2b-256 |
2afda9264bbeeab41fd1ace23220895f5113448804f2c7949e5c8b5ce60c0768
|
File details
Details for the file dlgram-3.0.0-py3-none-any.whl.
File metadata
- Download URL: dlgram-3.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8427cf7bb8dd5eab26213b1d904379074b85a65fc1fe098b02e048a7bfec846c
|
|
| MD5 |
46e8ee7d6050009b1a7164b0daf549ce
|
|
| BLAKE2b-256 |
e3c75c1db77dd0d12ca3faf5b48238c04a19852a24c5e03e8b057c60aa9ece6f
|