Fork of Pyrogram. Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
Project description
๐ฅ Pyromodify
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
โจ Features
|
โก 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 |
๐ฆ Installation
Stable Release
pip install pyromodify
Development Version
pip install git+https://github.com/Snowball-01/Pyromodify.git
With Performance Extras
pip install "pyromodify[fast]"
Note: The
fastextra installsPyTgCryptofor accelerated crypto operations anduvloopfor a faster event loop (Linux/macOS only).
๐ Quick Start
Bot Example
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()
Userbot Example
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()
๐ฌ Conversation Flow
One of Pyromodify's standout features is its builtโin conversation support โ no extra plugins required.
ask() โ Prompt and Wait
@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}**.")
listen() โ Wait for Any Update
@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!")
wait_for_callback_query() โ Inline Button Response
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)
register_next_step_handler() โ StepโBased Flows
@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}**")
๐๏ธ Handler Reference
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 |
๐๏ธ Project Structure
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
โ๏ธ Requirements
| 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) |
Core Dependencies
| Package | Purpose |
|---|---|
pyaes |
AES encryption (<=1.6.1) |
pysocks |
SOCKS proxy support (<=1.7.1) |
Optional Extras
# Speed boost (PyTgCrypto + uvloop)
pip install "pyromodify[fast]"
# Documentation generation
pip install "pyromodify[docs]"
# Development tools (pytest, hatch, twine)
pip install "pyromodify[dev]"
๐ Documentation
Full API documentation is built with Sphinx using the Furo theme.
Build Locally
# Create virtual environment & install deps
make venv
# Generate API reference + build HTML docs
make docs
# Live-reload mode for development
make docs-live
The generated docs will be available at docs/build/html/index.html.
๐ค Contributing
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
pytest
๐ License
Pyromodify 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.
๐ Links
Made with โค๏ธ by the Snowball-01 team
If you find Pyromodify useful, consider giving it a โญ on GitHub!
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 pyromodify-2.3.22.tar.gz.
File metadata
- Download URL: pyromodify-2.3.22.tar.gz
- Upload date:
- Size: 568.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efa551f388f6f9c79c40efa7f5274f153725ef239636d4b855803435c2167523
|
|
| MD5 |
43df52ed04ed79106aeab4987c8031ac
|
|
| BLAKE2b-256 |
c70f18c2d152610df38b8822b3734f58634b9a54dc2e5d73f64387402bcb7aa3
|
File details
Details for the file pyromodify-2.3.22-py3-none-any.whl.
File metadata
- Download URL: pyromodify-2.3.22-py3-none-any.whl
- Upload date:
- Size: 5.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cba8e18c6bdc6d6169138bbdab0cc45ba721c5579a48615e52ef7ef74cf5d9e0
|
|
| MD5 |
f84ab570b83b946eaed4d3470596695a
|
|
| BLAKE2b-256 |
734ff3ba10fad806eb71ab543af7d0a234ab665d3c9e507415b94994a5f2df41
|