DLGram
DLGram 3.21.0 · Pyrogram-compatible · mobile docs

Fast Telegram MTProto docs that fit your phone.

Install DLGram from GitHub, build bots with low RAM settings, use premium emoji buttons, stream media, and search every client/message method from this repo.

pip install --no-cache-dir --force-reinstall \
  "git+https://github.com/growxupdate/dlgram.git"

from pyrogram import Client, filters, types

app = Client(
    "bot",
    api_id=API_ID,
    api_hash=API_HASH,
    bot_token=BOT_TOKEN,
    msg_cache=300,
    update_queue=1000,
    smart_updates=True,
)
Low RAM modeUse msg_cache, update_queue, and smart_updates.
Button colorscolor="green", colour="red", or fallback default.
Media downloadsmsg.download(), download_media(), stream_media().

Install

DLGram keeps the pyrogram import path for compatibility, so most old bot code can run after reinstalling from this repo.

pip uninstall -y pyrogram pyrofork kurigram dlgram
pip cache purge
pip install --no-cache-dir --force-reinstall \
  "git+https://github.com/growxupdate/dlgram.git"

Optional speedup: install tgcrypto. If it fails on Termux, DLGram still works; crypto is just slower.

Quick start bot

Minimal bot with low-RAM defaults and a callback button.

from pyrogram import Client, filters, types

API_ID = 12345
API_HASH = "your_api_hash"
BOT_TOKEN = "your_bot_token"

app = Client(
    "test_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(_, m):
    await m.reply("DLGram OK")

app.run()

Premium emoji buttons

Use simple button colors directly. Unsupported colors fall back to default and show a warning.

color="green"colour="red"style="blue"icon_emoji_id
from pyrogram import types

HEART = "6267032805910254913"
MSG = "6266764202950530136"

keyboard = types.InlineKeyboardMarkup([
    [types.InlineKeyboardButton(
        "Play",
        callback_data="play",
        color="green",
        icon_emoji_id=HEART,
    )],
    [types.InlineKeyboardButton(
        "Stop",
        callback_data="stop",
        colour="red",
    )],
])

text = f'💬 DLGram test'
await message.reply(text, reply_markup=keyboard)

Downloads & streaming

There are three friendly APIs, but the low-level downloader is the same get_file() path.

Save to fileawait msg.download() or await app.download_media(msg)
Stream chunksasync for chunk in app.stream_media(msg)

Direct final filename

Use no_temp=True when you do not want a .temp file.

path = await msg.download(
    file_name="xyz.m4a",
    no_temp=True,
)

# Same thing through Client
path = await app.download_media(
    msg,
    file_name="xyz.m4a",
    no_temp=True,
)

Download from file_id only

file_id = message.audio.file_id
path = await app.download_media(
    file_id,
    file_name="song.m4a",
    no_temp=True,
)

A Message is not always required. A media object or file_id string can be enough. A Message/media object is still better when you want filename, file size, MIME type, progress total, or negative stream offsets.

Method search

Search client methods and Message/Story shortcuts generated from the repo. Try copy, send photo, download, stars, ask, or forum.

No method found. Try another keyword.

Low RAM config

Recommended for high-traffic groups:

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 sessions should disable updates and caches:

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,
)

Auto build & docs

Push to GitHub, then Actions can build wheel/sdist artifacts and deploy this static docs page with GitHub Pages.

git add .
git commit -m "Update DLGram docs"
git push

Security notes

  • Never print or send BOT_TOKEN, API_HASH, session strings, or database URIs.
  • Keep eval/shell execution out of public bot commands.
  • Use GitHub secrets for deploy credentials; do not hardcode tokens in docs/build scripts.

Attribution

DLGram is a fork/derived work built on Pyrogram/Pyrofork style APIs and remains under LGPL-compatible notices in the source. Keep upstream notices and license files intact when redistributing.