A modified pyromod by a.devh.in
Project description
PatchPyro
This is a fork of pyromod (renamed as patchpyro) for personal usecases.
Remember that this fork contains only conversation patch.
Requirements:
kurigram>=2.0.69
python>=3.9
Installation:
python -m pip install patchpyro
Usage:
Import patchpyro 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
from patchpyro import listen # or import patchpyro.listen
from pyrogram import Client
listen.thank() # use this if ur linters/ide is removing patchpyro as unused import.
mybot = Client("mysession")
# any other .py
from config import mybot
# no need to import patchpyro again pyrogram is already monkeypatched globally (at the same proccess)
patchpyro.listen
Just import it, it will automatically do the monkeypatch and you'll get these new methods:
- Available bound methods::
-
Chat.listen, User.listenawait mybot.listen(chat_id, filters=None, timeout=30)- raises
asyncio.TimeoutErrorif timeout (optional parameter) - 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
-
Chat.ask, User.askawait mybot.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.
-
Chat.asker, User.askerawait mybot.asker(chat_id, filters=None, timeout=36)- same as
.listen()but.asker()returnsNoneinstead of raisingasyncio.TimeoutError. - Found useful in some cases for me,
.asker()has a default timeout of 2 minutes. - You can adjust it by passing as a argument. Refer the example code given below.
-
Examples:
For .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 if no reply received.
return await sendx.reply_text("How long should I wait?, Eh! Bye!")
await answer.reply_text(f"{answer.text}, That's a cool name!")
...
For .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+)
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
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 patchpyro-2.1.0.tar.gz.
File metadata
- Download URL: patchpyro-2.1.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6e99318c4d8e8b573ce3e9311d752743ab5602f504750d5f78af536b5e01df
|
|
| MD5 |
f3f0144e23a11933ea8bad1354ca2053
|
|
| BLAKE2b-256 |
b51930ba7293a4026f2de2054790bf32351323eee3dd0c611af4aedec901526c
|
File details
Details for the file patchpyro-2.1.0-py3-none-any.whl.
File metadata
- Download URL: patchpyro-2.1.0-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6772938c1ce775adc080dd470f3af5fdd0c3be6f35078f5386f2ba57f77c733
|
|
| MD5 |
30fda312d2acbd523a2d7a6f012d88d5
|
|
| BLAKE2b-256 |
d98d75a09dd7c5eee17939e8b9c2c450de011981d84c7fe94865881fd8efc6cb
|