Skip to main content

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.

Python PyPI License Telegram


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 fast extra installs PyTgCrypto for accelerated crypto operations and uvloop for 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

GitHub Issues Telegram PyPI


Made with โค๏ธ by the Snowball-01 team

If you find Pyromodify useful, consider giving it a โญ on GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyromodify-2.3.22.tar.gz (568.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyromodify-2.3.22-py3-none-any.whl (5.5 MB view details)

Uploaded Python 3

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

Hashes for pyromodify-2.3.22.tar.gz
Algorithm Hash digest
SHA256 efa551f388f6f9c79c40efa7f5274f153725ef239636d4b855803435c2167523
MD5 43df52ed04ed79106aeab4987c8031ac
BLAKE2b-256 c70f18c2d152610df38b8822b3734f58634b9a54dc2e5d73f64387402bcb7aa3

See more details on using hashes here.

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

Hashes for pyromodify-2.3.22-py3-none-any.whl
Algorithm Hash digest
SHA256 cba8e18c6bdc6d6169138bbdab0cc45ba721c5579a48615e52ef7ef74cf5d9e0
MD5 f84ab570b83b946eaed4d3470596695a
BLAKE2b-256 734ff3ba10fad806eb71ab543af7d0a234ab665d3c9e507415b94994a5f2df41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page