# pyrosexmod
A monkeypatcher add-on for Pyrosex
## Introduction
pyrosexmod is a compilation of utils i developed for extend my personal use of Pyrosex. 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 pyrosex, this is *not* a fork nor modded version. It does monkey patching to add features to Pyrosex classes.
IMPORTANT: you should have installed asyncio pyrosex.
## Usage
Import `pyrosexmod` at least one time in your script, so you'll be able to use modified pyrosex in all files of the same proccess. Example:
```python
# config.py
import pyrosexmod.listen
from pyrosex import Client
app = Client('my_session')
```
```python
# any other .py
from config import app
# no need to import pyrosexmod again, pyrosex 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 `pyrosexmod.helpers`, which provides classes and functions that should be explicitely imported).
### `pyrosexmod.listen`
Just import it, it will automatically do the monkeypatch and you'll get these new methods:
- `await pyrosex.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 pyrosex.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:
```python
from pyrosexmod import listen # or import pyrosexmod.listen
from pyrosex 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}')
```
### `pyrosexmod.filters`
Import it and the following Update Filters will be monkeypatched to `pyrosex.filters`:
- `filters.dice`
A dice message.
### Copyright & License
This project may include snippets of Pyrosex code
- Pyrosex - Telegram MTProto API Client Library for Python. Copyright (C) 2017-2020 Dan <<https://github.com/OTHFamily>>
Licensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)
Raw data
{
"_id": null,
"home_page": "https://github.com/OnTheHerd/pyrosexmod",
"name": "pyrosexmod",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "OTH",
"author_email": "oth@pyrosex.org",
"download_url": "https://files.pythonhosted.org/packages/70/9e/77e74d29ac874f88e101379b64fadf7148a38f0cc5c110a056c2ac81ad03/pyrosexmod-0.2.1.tar.gz",
"platform": null,
"description": "# pyrosexmod\nA monkeypatcher add-on for Pyrosex\n\n## Introduction\npyrosexmod is a compilation of utils i developed for extend my personal use of Pyrosex. Then i started to use it and more bots and now i published it to make it easier to be installed in new projects.\nIt works *together* with pyrosex, this is *not* a fork nor modded version. It does monkey patching to add features to Pyrosex classes.\n\nIMPORTANT: you should have installed asyncio pyrosex.\n\n## Usage\nImport `pyrosexmod` at least one time in your script, so you'll be able to use modified pyrosex in all files of the same proccess. Example:\n```python\n# config.py\nimport pyrosexmod.listen\nfrom pyrosex import Client\n\napp = Client('my_session')\n```\n```python\n# any other .py\nfrom config import app\n# no need to import pyrosexmod again, pyrosex is already monkeypatched globally (at the same proccess)\n```\n\nI 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 `pyrosexmod.helpers`, which provides classes and functions that should be explicitely imported).\n\n### `pyrosexmod.listen`\nJust import it, it will automatically do the monkeypatch and you'll get these new methods:\n- `await pyrosex.Client.listen(chat_id, filters=None, timeout=30)`\nAwaits for a new message in the specified chat and returns it\nYou can pass Update Filters to the filters parameter just like you do for the update handlers. e.g. `filters=filters.photo & filters.bot`\n\n- `await pyrosex.Client.ask(text, chat_id, filters=None, timeout=30)`\nSame of `.listen()` above, but sends a message before awaiting\nYou can pass custom parameters to its send_message() call. Check the example below.\n\n- The bound methods `Chat.listen`, `User.listen`, `Chat.ask` and `User.ask`\n\nExample:\n```python\nfrom pyrosexmod import listen # or import pyrosexmod.listen\nfrom pyrosex import Client\nclient = Client(...)\n...\n answer = await client.ask(chat_id, '*Send me your name:*', parse_mode='Markdown')\n await client.send_message(chat_id, f'Your name is: {answer.text}') \n```\n\n### `pyrosexmod.filters`\nImport it and the following Update Filters will be monkeypatched to `pyrosex.filters`:\n\n- `filters.dice`\nA dice message.\n\n### Copyright & License\nThis project may include snippets of Pyrosex code\n- Pyrosex - Telegram MTProto API Client Library for Python. Copyright (C) 2017-2020 Dan <<https://github.com/OTHFamily>>\n\nLicensed under the terms of the [GNU Lesser General Public License v3 or later (LGPLv3+)](COPYING.lesser)\n",
"bugtrack_url": null,
"license": "LGPLv3+",
"summary": "A monkeypatcher add-on for Pyrosex",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/OnTheHerd/pyrosexmod"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "87f74ff9f4df1901ecab8720ee0f7e3313bd97637b8f971be5ee554ccb26cee5",
"md5": "966f6b23cccb7274e09413a0ed71deb2",
"sha256": "38ae7b133bad891645b5417c566c0e01acb2e5a5fd576a3ab54d58f6b82fc90d"
},
"downloads": -1,
"filename": "pyrosexmod-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "966f6b23cccb7274e09413a0ed71deb2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 21995,
"upload_time": "2023-06-19T10:16:26",
"upload_time_iso_8601": "2023-06-19T10:16:26.215235Z",
"url": "https://files.pythonhosted.org/packages/87/f7/4ff9f4df1901ecab8720ee0f7e3313bd97637b8f971be5ee554ccb26cee5/pyrosexmod-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "709e77e74d29ac874f88e101379b64fadf7148a38f0cc5c110a056c2ac81ad03",
"md5": "80bd6dae8375c7796dd9c4d5b9f7c654",
"sha256": "c74a3b62450b56d7070b8e003e1e720414094a88b48381be2f16ad8d612280f0"
},
"downloads": -1,
"filename": "pyrosexmod-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "80bd6dae8375c7796dd9c4d5b9f7c654",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 20584,
"upload_time": "2023-06-19T10:16:27",
"upload_time_iso_8601": "2023-06-19T10:16:27.733872Z",
"url": "https://files.pythonhosted.org/packages/70/9e/77e74d29ac874f88e101379b64fadf7148a38f0cc5c110a056c2ac81ad03/pyrosexmod-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-19 10:16:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "OnTheHerd",
"github_project": "pyrosexmod",
"github_not_found": true,
"lcname": "pyrosexmod"
}