msg_cache, update_queue, and smart_updates.color="green", colour="red", or fallback default.msg.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()
Downloads & streaming
There are three friendly APIs, but the low-level downloader is the same get_file() path.
await msg.download() or await app.download_media(msg)async 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.
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.