Skip to main content

PatchPyro

This is a fork of pyromod (renamed as patchpyro) for personal usecases.

Remember that this fork contains only conversation patch.

Requirements:

pyrogram>=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

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.listen

      • await mybot.listen(chat_id, filters=None, timeout=30)
      • raises asyncio.TimeoutError if 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.ask

      • await 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.asker

      • await mybot.asker(chat_id, filters=None, timeout=36)
      • same as .listen() but .asker() returns None instead of raising asyncio.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='Markdown')
    await client.send_message(chat_id, f'Your name is: {answer.text}')
...

Copyright & License

This project may include snippets of Pyrogram code

Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)

Download files

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

Source Distribution

patchpyro-2.0.2.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

patchpyro-2.0.2-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file patchpyro-2.0.2.tar.gz.

File metadata

  • Download URL: patchpyro-2.0.2.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for patchpyro-2.0.2.tar.gz
Algorithm Hash digest
SHA256 1efea56c628fccc3b13f187324daee787011e522e8d8345b68c63c0e074b7af7
MD5 64bf85c6486129f8843a883c06343bf2
BLAKE2b-256 676731ed811e1523d425cfb1a4a6cf76f864083929bc0d3a96d277ae3958b97f

See more details on using hashes here.

File details

Details for the file patchpyro-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: patchpyro-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for patchpyro-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a126dc2c53c183af572b56ec7b4110b932f908bc5b36140b3745f405b410e07f
MD5 82c60a45d565fff5a0c138c53c8e715c
BLAKE2b-256 e299bc2fefb6483bc59cc8f035ff0239a9cf6601bac26a77ca6892430a3673df

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 Sentry Error logging StatusPage Status page