Skip to main content

A monkeypatcher add-on for Pyrogram

Project description

pyromod

A monkeypatcher add-on for Pyrogram

Introduction

pyromod is a compilation of utils i developed for extend my personal use of Pyrogram. Then i started to use it and more bots and now i published it to make it easier to be installed in new projects. It works together with pyrogram, this is not a fork nor modded version. It does monkey patching to add features to Pyrogram classes.

IMPORTANT: you should have installed asyncio pyrogram.

Usage

Import pyromod 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 pyromod.listen
from pyrogram import Client

app = Client('my_session')
# any other .py
from config import app
# no need to import pyromod again, pyrogram is already monkeypatched globally (at the same proccess)

I separated the patches between packages to allow you to import only what you want. The __init__.py of each package does the monkeypatch automatically as soon as they are imported (except for pyromod.helpers, which provides classes and functions that should be explicitely imported).

pyromod.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.ask and User.ask

Example:

from pyromod import listen # or import pyromod.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}')    

pyromod.filters

Import it and the following Update Filters will be monkeypatched to pyrogram.Filters:

  • Filters.dice A dice message.

  • Filters.callback_regex(pattern, flags: int = 0) Same of Filters.regex, but for CallbackQuery updates The CallbackQuery object will hold the matches on the new CallbackQuery.matches attribute (just like Message.matches)

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+)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyromod-0.0.6-py3.8.egg (20.7 kB view details)

Uploaded Source

pyromod-0.0.6-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file pyromod-0.0.6-py3.8.egg.

File metadata

  • Download URL: pyromod-0.0.6-py3.8.egg
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.0

File hashes

Hashes for pyromod-0.0.6-py3.8.egg
Algorithm Hash digest
SHA256 e9ad4883d1ba62f68c68d14fa9a6060f0b5aace6c8dc2939282dd61d22b75b85
MD5 0477db87d031c6e30612fa3adf83e724
BLAKE2b-256 c74aeea6d4534a9fe4842df1698aa3f8333587ecbeccc37c311e632d7c7947ad

See more details on using hashes here.

File details

Details for the file pyromod-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: pyromod-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.0

File hashes

Hashes for pyromod-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 47d59d575ffce9801ea74fbef758be232245009eeabb29163e74089d05df6c6c
MD5 702dd23ad1cd58f50ea496f88805f2f6
BLAKE2b-256 555d1eac44c278b545df73c40824b0be7ddc6b4d43a6dce9be07fcca28ec42c6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page