Elegant, Modern & Asynchronous Telegram MTProto API Framework
A powerful fork of Pyrogram with built-in conversation handling, Pyromod-style flows, and modern Telegram Bot API support.
Features • Installation • Quick Start • Conversations • Handlers • Structure • License
|
⚡ Async-First Fully asynchronous architecture built on asyncio for high‑performance I/O
|
💬 Conversation Flow Built‑in Pyromod‑style ask(), listen(), and step handlers for interactive dialogs
|
🤖 Dual Mode Seamlessly works with both user accounts and bot accounts via MTProto |
🛡️ Type‑Safe Comprehensive type hints across all core modules for IDE autocomplete & safety |
|
🎯 20+ Handlers Message, callback, inline, reaction, story, poll, payment, and more event handlers |
📦 Rich Types Full coverage of Telegram types — messages, media, keyboards, business, stories |
🔐 Crypto Layer Built‑in encryption with optional PyTgCrypto and uvloop acceleration
|
📝 Sphinx Docs Auto-generated API reference with Sphinx, Furo theme, and copy‑button support |
pip install pyromodifypip install git+https://github.com/Snowball-01/Pyromodify.gitpip install "pyromodify[fast]"Note: The
fastextra installsPyTgCryptofor accelerated crypto operations anduvloopfor a faster event loop (Linux/macOS only).
from pyrogram import Client, filters
app = Client(
"my_bot",
api_id=123456,
api_hash="your_api_hash",
bot_token="123456:ABCDEF"
)
@app.on_message(filters.command("start") & filters.private)
async def start(client, message):
await message.reply(
"👋 **Hello!** Welcome to my bot.\n"
"Powered by **Pyromodify**."
)
app.run()from pyrogram import Client, filters
app = Client(
"my_account",
api_id=123456,
api_hash="your_api_hash"
)
@app.on_message(filters.me & filters.command("ping", prefixes="."))
async def ping(client, message):
await message.edit_text("🏓 **Pong!**")
app.run()One of Pyromodify's standout features is its built‑in conversation support — no extra plugins required.
@app.on_message(filters.command("survey"))
async def survey(client, message):
# Ask a question and wait for the user's response
response = await message.chat.ask("What is your name?")
name = response.text
response = await message.chat.ask(f"Nice to meet you, {name}! How old are you?")
age = response.text
await message.reply(f"✅ Got it! **{name}**, age **{age}**.")@app.on_message(filters.command("wait"))
async def wait_example(client, message):
await message.reply("Send me a photo within 30 seconds!")
response = await client.listen(
chat_id=message.chat.id,
filters=filters.photo,
timeout=30
)
await response.reply("📸 Photo received!")from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
@app.on_message(filters.command("choose"))
async def choose(client, message):
keyboard = InlineKeyboardMarkup([
[InlineKeyboardButton("Option A", callback_data="a"),
InlineKeyboardButton("Option B", callback_data="b")]
])
await message.reply("Pick one:", reply_markup=keyboard)
cb = await client.wait_for_callback_query(message.chat.id)
await cb.answer(f"You picked: {cb.data.upper()}", show_alert=True)@app.on_message(filters.command("multistep"))
async def step_one(client, message):
await message.reply("Step 1: Send your email address.")
client.register_next_step_handler(message, step_two)
async def step_two(client, message):
email = message.text
await message.reply(f"Got **{email}**. Now send your phone number.")
client.register_next_step_handler(message, step_three)
async def step_three(client, message):
phone = message.text
await message.reply(f"✅ Registration complete! Phone: **{phone}**")Pyromodify ships with 20+ event handlers covering every Telegram update type:
| Handler | Decorator | Description |
|---|---|---|
MessageHandler |
@on_message |
New incoming/outgoing messages |
EditedMessageHandler |
@on_edited_message |
Edited messages |
DeletedMessagesHandler |
@on_deleted_messages |
Deleted messages |
CallbackQueryHandler |
@on_callback_query |
Inline button presses |
InlineQueryHandler |
@on_inline_query |
Inline mode queries |
ChosenInlineResultHandler |
@on_chosen_inline_result |
Chosen inline results |
ChatMemberUpdatedHandler |
@on_chat_member_updated |
Chat member status changes |
ChatJoinRequestHandler |
@on_chat_join_request |
Join requests |
MessageReactionUpdatedHandler |
@on_message_reaction_updated |
Message reactions |
MessageReactionCountUpdatedHandler |
@on_message_reaction_count_updated |
Reaction count changes |
StoryHandler |
@on_story |
Stories |
PollHandler |
@on_poll |
Poll updates |
UserStatusHandler |
@on_user_status |
Online/offline status |
ConversationHandler |
— | Pyromod conversation flow |
PreCheckoutQueryHandler |
@on_pre_checkout_query |
Pre-checkout payment queries |
ShippingQueryHandler |
@on_shipping_query |
Shipping queries |
PurchasedPaidMediaHandler |
@on_bot_purchased_paid_media |
Purchased paid media |
BusinessBotConnectionHandler |
@on_bot_business_connection |
Business bot connections |
RawUpdateHandler |
@on_raw_update |
Raw MTProto updates |
DisconnectHandler |
@on_disconnect |
Client disconnect events |
Pyromodify/
├── pyrogram/ # Core library
│ ├── client.py # Main Client class
│ ├── dispatcher.py # Update dispatcher engine
│ ├── filters.py # Message & update filters
│ ├── sync.py # idle() & compose() utilities
│ ├── utils.py # Internal helpers
│ ├── file_id.py # Telegram file ID parser
│ ├── handlers/ # 20+ event handlers
│ │ ├── message_handler.py
│ │ ├── callback_query_handler.py
│ │ ├── conversation_handler.py
│ │ └── ...
│ ├── methods/ # Client API methods
│ │ ├── messages/ # Send, edit, delete messages
│ │ ├── chats/ # Chat management
│ │ ├── users/ # User info & actions
│ │ ├── bots/ # Bot-specific methods
│ │ ├── pyromod/ # ask(), listen(), step handlers
│ │ ├── decorators/ # @on_message, @on_callback, ...
│ │ ├── stickers/ # Sticker operations
│ │ ├── stories/ # Stories
│ │ ├── business/ # Business features
│ │ └── ...
│ ├── types/ # Telegram type definitions
│ │ ├── messages_and_media/ # Message, Photo, Video, ...
│ │ ├── user_and_chats/ # User, Chat, ChatMember, ...
│ │ ├── bots_and_keyboards/ # InlineKeyboard, ReplyKeyboard
│ │ ├── inline_mode/ # InlineQuery, InlineResult
│ │ ├── pyromod/ # Listener, Identifier
│ │ └── ...
│ ├── enums/ # Enumerations (ChatType, ParseMode, ...)
│ ├── errors/ # Telegram error mapping
│ ├── connection/ # TCP/Transport layer
│ ├── session/ # MTProto session management
│ ├── storage/ # SQLite session storage
│ ├── crypto/ # Encryption utilities
│ ├── parser/ # HTML & Markdown parsers
│ └── raw/ # Auto-generated TL schema bindings
├── compiler/ # TL schema & docs compilers
│ ├── api/ # API schema compiler
│ ├── errors/ # Error code compiler
│ └── docs/ # Documentation compiler
├── tests/ # Test suite (pytest)
├── docs/ # Sphinx documentation source
├── pyproject.toml # Project metadata & build config
├── hatch_build.py # Custom Hatch build hook
├── Makefile # Development shortcuts
├── COPYING # GPL-3.0 license
├── COPYING.lesser # LGPL-3.0 license
└── NOTICE # Attribution notice
| Requirement | Details |
|---|---|
| Python | >= 3.9 (CPython or PyPy) |
| API Credentials | api_id + api_hash from my.telegram.org |
| Bot Token | From @BotFather (for bot mode only) |
| Package | Purpose |
|---|---|
pyaes |
AES encryption (<=1.6.1) |
pysocks |
SOCKS proxy support (<=1.7.1) |
# Speed boost (PyTgCrypto + uvloop)
pip install "pyromodify[fast]"
# Documentation generation
pip install "pyromodify[docs]"
# Development tools (pytest, hatch, twine)
pip install "pyromodify[dev]"Full API documentation is built with Sphinx using the Furo theme.
# Create virtual environment & install deps
make venv
# Generate API reference + build HTML docs
make docs
# Live-reload mode for development
make docs-liveThe generated docs will be available at docs/build/html/index.html.
Contributions are welcome! Here's how to get started:
# Clone the repository
git clone https://github.com/Snowball-01/Pyromodify.git
cd Pyromodify
# Create a virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# venv\Scripts\activate # Windows
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytestPyromodify is licensed under the GNU Lesser General Public License v3.0 (LGPL-3.0).
This means you can:
- ✅ Use it in proprietary projects
- ✅ Modify and distribute it
⚠️ Changes to the library itself must remain open-source
See COPYING and COPYING.lesser for full terms.
Made with ❤️ by the Snowball-01 team
If you find Pyromodify useful, consider giving it a ⭐ on GitHub!