pyroaddon
A monkeypatcher add-on for Pyrogram
Introduction
pyroaddon contains the same functionalities as pyromod plus some more. So basically it's pyromod on steroids.
pyroaddon works together with pyrogram, this is not a fork nor modded version. It does monkey patching to add features to Pyrogram classes.
Usage
Import pyroaddon at least one time in your script, so you'll be able to use modified pyrogram in all files of the same proccess. Example:
# config.py
import pyroaddon
from pyrogram import Client
app = Client('my_session')
# any other .py
from config import app
# no need to import pyroaddon again, pyrogram is already monkeypatched globally (at the same proccess)
New Features
Message.input
Import pyroaddon to add the property input to pyrogram.types.Message. When a message contains a command, Message.input will contain the text in front of the command if there are any.
Example: if /command text in front is in message.text, Then Message.input = "text in front"
Note: Message.input will preserve any spaces between the text.
Client.get_all_groups
pyrogram.Client.get_all_groups() will return any group chats that the client is joined in.
Client.get_chat_administrators
pyrogram.Client.get_chat_administrators(chat_id, has_creator=False) will return chat administrators. If has_creator is set to True, It will also contain the owner.
pyroaddon.filters
Import it and the following Update Filters will be monkeypatched to pyrogram.filters:
filters.video_stickerA video sticker message.filters.ttl_messageA ttl message.
Old Features
pyroaddon.listen
Just import it, it will automatically do the monkeypatch and you'll get these new methods:
-
await pyrogram.Client.listen(chat_id, filters=None, timeout=30)Awaits for a new message in the specified chat and returns it You can pass Update Filters to the filters parameter just like you do for the update handlers. e.g.filters=filters.photo & filters.bot -
await pyrogram.Client.ask(text, chat_id, filters=None, timeout=30)Same of.listen()above, but sends a message before awaiting You can pass custom parameters to its send_message() call. Check the example below. -
The bound methods
Chat.listen,User.listen,Chat.askandUser.ask
Example:
from pyroaddon import listen # or import pyroaddon.listen
from pyrogram import Client
client = Client(...)
...
answer = await client.ask(chat_id, '*Send me your name:*', parse_mode='Markdown')
await client.send_message(chat_id, f'Your name is: {answer.text}')
pyroaddon.nav
Tools for creating navigation keyboards.
pyroaddon.nav.PaginationCreates a full pagination keyboard. Usage:
from pyrogram import Client, filters
from pyroaddon.nav import Pagination
from pyroaddon.helpers import ikb
def page_data(page):
return f'view_page {page}'
def item_data(item, page):
return f'view_item {item} {page}'
def item_title(item, page):
return f'Item {item} of page {page}'
@Client.on_message(filters.regex('/nav'))
async def on_nav(c,m):
objects = [*range(1,100)]
page = Pagination(
objects,
page_data=page_data, # callback to define the callback_data for page buttons in the bottom
item_data=item_data, # callback to define the callback_data for each item button
item_title=item_title # callback to define the text for each item button
)
index = 0 # in which page is it now?
lines = 5 # how many lines of the keyboard to include for the items
columns = how many columns include in each items' line
kb = page.create(index, lines, columns)
await m.reply('Test', reply_markup=ikb(kb))
pyroaddon.helpers
Tools for creating inline keyboards a lot easier.
pyroaddon.helpers.ikbCreates a inline keyboard. It's first and only argument must be a list (the keyboard) containing lists (the lines) of buttons. The buttons can also be lists or tuples. I use tuples to not have to deal with a lot of brackets. The button syntax must be this: (TEXT, CALLBACK_DATA) or (TEXT, VALUE, TYPE), where TYPE can be 'url' or any other supported button type and VALUE is its value. This syntax will be converted to {"text": TEXT, TYPE: VALUE). If TYPE is CALLBACK_DATA, you can omit it, just like the fist syntax above. Examples:
from pyroaddon.helpers import ikb
...
keyboard = ikb([
[('Button 1', 'call_1'), ('Button 2', 'call_2')],
[('Another button', 't.me/pyroaddon', 'url')]
])
await message.reply('Test', reply_markup=keyboard)
pyroaddon.helpers.array_chunkChunk the elements of a list into small lists. i.e. [1, 2, 3, 4] can become [[1,2], [3,4]]. This is extremely useful if you want to build a keyboard dinamically with more than 1 column. You just put all buttons together in a list and run:
lines = array_chunk(buttons, 2) # generate a list of lines with 2 buttons on each
keyboard = ikb(lines)
Copyright & License
This project may include snippets of Pyrogram code
- Pyrogram - Telegram MTProto API Client Library for Python. Copyright (C) 2017-2022 Dan <https://github.com/delivrance>
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)
Metadata
Release files for pyroaddon 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyroaddon-1.0.6.tar.gz | 22.5 kB | Without provenance | Details for pyroaddon-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyroaddon-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for pyroaddon-1.0.6-py3-none-any.whl |
Total release size: 49.3 kB
Release files / pyroaddon-1.0.6.tar.gz
| Download URL | pyroaddon-1.0.6.tar.gz |
|---|---|
| Size | 22.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ba1dc0687cb66fdfb529b60cc41a484aed9c783201a1283a0867bb28019f889
|
|
BLAKE2b-256 checksum How to use checksums |
ecd457de40267b7117d646cd5a1b2d366ea6ad4bb26ee84edf7c246e8d6ca580
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / pyroaddon-1.0.6-py3-none-any.whl
| Download URL | pyroaddon-1.0.6-py3-none-any.whl |
|---|---|
| Size | 26.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b0f6b75e76caac4a108f56d9ffae9bfe0a09443fa04bee7c1331e3d3f50266b
|
|
BLAKE2b-256 checksum How to use checksums |
b0ec179c84f1cad868f913aaa4adb466decd9101d84130200d3826f3cdad0be1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Security for pyroaddon 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.