PatchPyro
A fork of pyromod (renamed as patchpyro) providing conversation patches for Pyrogram-based clients.
Requirements
kurigram>=2.0.69
python>=3.9
Installation
pip install patchpyro
Usage
Import patchpyro at least once in your script so you can use the modified Pyrogram in all files of the same process.
Example
# config.py
from patchpyro import listen # or import patchpyro.listen
from pyrogram import Client
listen.thank() # use this if your linter/IDE flags patchpyro as an unused import.
mybot = Client("mysession")
# any other .py
from config import mybot
# no need to import patchpyro again; Pyrogram is already monkeypatched globally (in the same process)
Available Methods
Just importing patchpyro.listen will automatically do the monkeypatch and you'll get these new methods:
Chat.listen, User.listen
await mybot.listen(chat_id, filters=None, timeout=30)- Awaits a new message in the specified chat and returns it.
- Raises
asyncio.TimeoutErrorif timeout (optional parameter) occurs. - You can pass Update Filters to the filters parameter just like you do for the update handlers.
- E.g.
filters=filters.photo & filters.bot
- E.g.
Chat.ask, User.ask
await mybot.ask(text, chat_id, filters=None, timeout=30)- Same as
.listen()above, but sends a message before awaiting. - You can pass custom parameters to its internal
send_message()call. Check the example below.
Chat.asker, User.asker
await mybot.asker(chat_id, filters=None, timeout=36)- Same as
.listen()but.asker()returnsNoneinstead of raisingasyncio.TimeoutError. - Useful for graceful timeout handling,
.asker()has a default timeout of 2 minutes (adjustable viatimeoutargument).
Examples
asker()
# ...
sendx = await client.send_message(chat_id, "`Send me your name:`")
answer = await client.asker(chat_id, filters=None, timeout=60)
if not answer: # `None` if timeout reached with no reply.
return await sendx.reply_text("How long should I wait? Bye!")
await answer.reply_text(f"{answer.text}, That's a cool name!")
# ...
ask()
# ...
answer = await client.ask(chat_id, '*Send me your name:*', parse_mode=enums.ParseMode.MARKDOWN)
await client.send_message(chat_id, f'Your name is: {answer.text}')
# ...
Copyright & License
This project includes code from:
- kurimod: Monkeypatcher logic and modern async compatibility fixes.
- Pyrogram: Telegram MTProto API Client Library for Python. Copyright (C) 2017-2022 Dan <https://github.com/delivrance>
- pyromod: Original conversation patch logic.
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)
Metadata
Release files for patchpyro 2.1.1
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 |
|---|---|---|---|---|
| patchpyro-2.1.1.tar.gz | 21.1 kB | Without provenance | Details for patchpyro-2.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| patchpyro-2.1.1-py3-none-any.whl | Python 3 | none | any | Details for patchpyro-2.1.1-py3-none-any.whl |
Total release size: 45.3 kB
Release files / patchpyro-2.1.1.tar.gz
| Download URL | patchpyro-2.1.1.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce4f2b64d7f6316162375dd6f1886c95d93a80fa73d716ede96bf8e5c88c2363
|
|
BLAKE2b-256 checksum How to use checksums |
e4e749b6ea743eceffcf4915e8b712e5cb3584c57eb7a6acf7f1b371b0e2f65c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / patchpyro-2.1.1-py3-none-any.whl
| Download URL | patchpyro-2.1.1-py3-none-any.whl |
|---|---|
| Size | 24.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16853264e81eb50d203ac07f21d894ce24db954c2eec18dd440134c20b0df232
|
|
BLAKE2b-256 checksum How to use checksums |
a7530fc065751a731360930022668d575ce49ca58561fc30b586550fc38f3597
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for patchpyro 2.1.1
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.