Skip to content

Commit

Permalink
Update requirements.txt and README
Browse files Browse the repository at this point in the history
  • Loading branch information
usernein committed Apr 1, 2020
1 parent 967376a commit 700ad20
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
# pyromod
A monkeypatched add-on for Pyrogram
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.
Note: it uses pyrogram asyncio.

## Usage
I separated the utils in packages, you should import them to do the monkeypatch (except for `pyromod.utils` with provides classes and functions to be explicitely imported):
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:
```python
# config.py
import pyromod.listen
from pyrogram import Client

app = Client('my_session')
```
```python
# 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.utils`, which provides classes and functions that should be explicitely imported).

### `pyromod.listen`
Just import it and you have these new methods:
- `await pyrogram.Client.listen(chat_id, timeout=30)`
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, timeout=30)`
- `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`

Usage:
Example:
```python
from pyromod import listen # or import pyromod.listen
from pyrogram import Client
client = Client(...)
...
answer = await client.ask('Confirm? [Yn]', chat_id)
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
- Pyrogram - Telegram MTProto API Client Library for Python
- Copyright (C) 2017-2020 Dan <<https://github.com/delivrance>>

- Licensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyrogram @ https://api.github.com/repos/pyrogram/pyrogram/tarball/asyncio-dev
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
with open('requirements.txt') as fp:
requirements = [line.strip() for line in fp]

print(requirements)

setuptools.setup(
name="pyromod",
version="0.0.1",
version="0.0.2",
author="Cezar H.",
license="LGPLv3+",
description="A monkeypatched add-on for Pyrogram",
description="A monkeypatcher add-on for Pyrogram",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/usernein/pyromod",
Expand Down

0 comments on commit 700ad20

Please sign in to comment.