Telegram MTProto API Framework for Python
Homepage
•
Documentation
•
Issues
•
Support Chat
•
News/Releases
Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
from pyrogram import Client, filters
app = Client("my_account")
@app.on_message(filters.private)
async def hello(client, message):
await message.reply("Hello from PyroRatnaGram!")
app.run()PyroRatnaGram is a modern, elegant and asynchronous MTProto API framework. It enables you to easily interact with the main Telegram API through a user account (custom client) or a bot identity (bot API alternative) using Python.
- KeyboardButton now supports style and icon_custom_emoji_id for richer reply keyboards.
- Available ButtonStyle colors are PRIMARY (blue), DANGER (red), and SUCCESS (green).
- Callback query handlers now support clear priority flow with group usage.
- Documentation and project links were updated to the current PyroRatnaGram endpoints.
- Package publishing identity is now pyroratnagram. Use pip3 install -U pyroratnagram for new installs and upgrades.
- For private incoming text handlers, command exclusion should be moved to decorator-level filtering.
Old style:
@Client.on_message(filters.private & filters.text & filters.incoming)
async def pm_search(client, message):
if str(message.text).startswith('/'):
returnRecommended style:
@Client.on_message(filters.private & filters.text & filters.incoming & filters.regex(r"^(?!/)"))
async def pm_search(client, message):
...Why this change matters: it prevents unnecessary handler execution, keeps handlers cleaner, and reduces logic duplication.
For the full list of updates, see CHANGELOG.md.
- Ready: Install PyroRatnaGram with pip and start building your applications right away.
- Easy: Makes the Telegram API simple and intuitive, while still allowing advanced usages.
- Elegant: Low-level details are abstracted and re-presented in a more convenient way.
- Fast: Boosted up by TgCrypto, a high-performance cryptography library written in C.
- Type-hinted: Types and methods are all type-hinted, enabling excellent editor support.
- Async: Fully asynchronous (also usable synchronously if wanted, for convenience).
- Powerful: Full access to Telegram's API to execute any official client action and more.
pip3 install -U pyroratnagram- Check out the docs at https://pyroratna.ratna.pw to learn more about PyroRatnaGram, get started right away and discover more in-depth material for building your client applications.
- Join the official Telegram Channel at https://t.me/official_RATNA and stay tuned for news, updates and announcements.