pyro-listener


Namepyro-listener JSON
Version 2023.9.19 PyPI version JSON
download
home_page
SummaryPyrogram listener
upload_time2023-09-19 14:24:14
maintainer
docs_urlNone
authorZAID
requires_python~=3.7
license
keywords python pyrogram telegram
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
<p align="center">
    <a href="https://github.com/x72x/pyro-listener/">
        <img src="https://raw.githubusercontent.com/x72x/pyro-listener/main/assest/Screenshot%202023-09-14%20212426.png" alt="pyro-listener" width="">
    </a>
    <br>
    <b>Pyrogram listener</b>
    <br>
    <a href="https://github.com/x72x/pyro-listener/tree/main/examples">
        Examples
    </a>
    •
    <a href="https://t.me/Y88F8">
        News
    </a>
</p>

## Pyrolistener

> Message listener example

``` python
from pyrogram import Client, filters, types, idle
from pyrolistener import Listener

app = Client("name")

app.start()

listener = Listener(client=app, show_output=True)

@app.on_message(filters.command("start"))
async def _(c: Client, m: types.Message):
    msg = await listener.listen_to(m, "What's your name?", filters=["text"])
    return await msg.reply(f"Your name is {msg.text}")

print("run")
idle()
```

> callbackQuery listener example
```python
@app.on_callback_query()
async def _(c: Client, query: types.CallbackQuery):
    if query.data == "name":
        msg = await listener.listen_to(
            query,
            "Whats Your name ?",
            fiilters=["text"]
        )
        return await msg.reply(f"Your Name is {msg.text}")
```

> TimeOut example
```python
@app.on_message(filters.command("start"))
async def __(c: Client, m: types.Message):
    try:
        msg = await listener.listen_to(
            m,
            "Send your name!",
            reply_markup=types.ForceReply(selective=True, placeholder="Your name"),
            filters=["text"],
            timeout=10
        )
    except exceptions.TimeOut:
        msg = None
        print("Time Out !")
        await m.reply("Time Out", quote=True)
    if msg:
        await msg.reply(f"Your name is {msg.text}", quote=True)
        # to delete client question message:
        await msg.output.delete()
```

> Advnced listener example
```python
@app.on_message(filters.photo)
async def _(c: Client, m: types.Message):
    await m.reply_photo(m.photo.file_id, caption="are you sure to add an button to the photo? send Y/N")
    msg = await listener.listen(
        m.chat.id,
        from_id=m.from_user.id,
        filters=["text"]
    )
    if msg.text.lower() == "y":
        return await msg.reply_photo(
            m.photo.file_id,
            reply_markup=types.InlineKeyboardMarkup(
                [[types.InlineKeyboardButton("button", "callback")]]
            )
        )
    elif msg.text.lower() == "n":
        return await msg.reply("Okay")
    else:
        return await msg.reply("Wrong choice")
```

> Filters type example
```python
@app.on_message(filters.command("ask") & filters.group)
async def _(c: Client, message: types.Message):
    msg = await listener.listen(
        chat_id=message.chat.id,
        text="What's your name",
        filters=["sender_chat", "text"],
        filters_type=2
    ) # will only listen to an message has "sender_chat" and "text" attribute
    msg = await listener.listen(
        chat_id=message.chat.id,
        text="What's your name",
        filters=["sender_chat", "text"],
        filters_type=1
    ) # will listen to any messgae has "sender_chat" or "text" attribute
    return await msg.reply(f"Youe name is {msg.text}")
```

### Installing

``` bash
pip3 install -U pyro-listener
```

### Community

- Join the telegram channel: https://t.me/Y88F8

### Examples
- https://github.com/x72x/pyro-listener/tree/main/examples

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pyro-listener",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.7",
    "maintainer_email": "",
    "keywords": "python,pyrogram,telegram",
    "author": "ZAID",
    "author_email": "y8838@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/36/71/e45b3183c5dee146de642a26f0c49d2022778f6d92608f0e26d2b4090a62/pyro-listener-2023.9.19.tar.gz",
    "platform": null,
    "description": "\n<p align=\"center\">\n    <a href=\"https://github.com/x72x/pyro-listener/\">\n        <img src=\"https://raw.githubusercontent.com/x72x/pyro-listener/main/assest/Screenshot%202023-09-14%20212426.png\" alt=\"pyro-listener\" width=\"\">\n    </a>\n    <br>\n    <b>Pyrogram listener</b>\n    <br>\n    <a href=\"https://github.com/x72x/pyro-listener/tree/main/examples\">\n        Examples\n    </a>\n    \u2022\n    <a href=\"https://t.me/Y88F8\">\n        News\n    </a>\n</p>\n\n## Pyrolistener\n\n> Message listener example\n\n``` python\nfrom pyrogram import Client, filters, types, idle\nfrom pyrolistener import Listener\n\napp = Client(\"name\")\n\napp.start()\n\nlistener = Listener(client=app, show_output=True)\n\n@app.on_message(filters.command(\"start\"))\nasync def _(c: Client, m: types.Message):\n    msg = await listener.listen_to(m, \"What's your name?\", filters=[\"text\"])\n    return await msg.reply(f\"Your name is {msg.text}\")\n\nprint(\"run\")\nidle()\n```\n\n> callbackQuery listener example\n```python\n@app.on_callback_query()\nasync def _(c: Client, query: types.CallbackQuery):\n    if query.data == \"name\":\n        msg = await listener.listen_to(\n            query,\n            \"Whats Your name ?\",\n            fiilters=[\"text\"]\n        )\n        return await msg.reply(f\"Your Name is {msg.text}\")\n```\n\n> TimeOut example\n```python\n@app.on_message(filters.command(\"start\"))\nasync def __(c: Client, m: types.Message):\n    try:\n        msg = await listener.listen_to(\n            m,\n            \"Send your name!\",\n            reply_markup=types.ForceReply(selective=True, placeholder=\"Your name\"),\n            filters=[\"text\"],\n            timeout=10\n        )\n    except exceptions.TimeOut:\n        msg = None\n        print(\"Time Out !\")\n        await m.reply(\"Time Out\", quote=True)\n    if msg:\n        await msg.reply(f\"Your name is {msg.text}\", quote=True)\n        # to delete client question message:\n        await msg.output.delete()\n```\n\n> Advnced listener example\n```python\n@app.on_message(filters.photo)\nasync def _(c: Client, m: types.Message):\n    await m.reply_photo(m.photo.file_id, caption=\"are you sure to add an button to the photo? send Y/N\")\n    msg = await listener.listen(\n        m.chat.id,\n        from_id=m.from_user.id,\n        filters=[\"text\"]\n    )\n    if msg.text.lower() == \"y\":\n        return await msg.reply_photo(\n            m.photo.file_id,\n            reply_markup=types.InlineKeyboardMarkup(\n                [[types.InlineKeyboardButton(\"button\", \"callback\")]]\n            )\n        )\n    elif msg.text.lower() == \"n\":\n        return await msg.reply(\"Okay\")\n    else:\n        return await msg.reply(\"Wrong choice\")\n```\n\n> Filters type example\n```python\n@app.on_message(filters.command(\"ask\") & filters.group)\nasync def _(c: Client, message: types.Message):\n    msg = await listener.listen(\n        chat_id=message.chat.id,\n        text=\"What's your name\",\n        filters=[\"sender_chat\", \"text\"],\n        filters_type=2\n    ) # will only listen to an message has \"sender_chat\" and \"text\" attribute\n    msg = await listener.listen(\n        chat_id=message.chat.id,\n        text=\"What's your name\",\n        filters=[\"sender_chat\", \"text\"],\n        filters_type=1\n    ) # will listen to any messgae has \"sender_chat\" or \"text\" attribute\n    return await msg.reply(f\"Youe name is {msg.text}\")\n```\n\n### Installing\n\n``` bash\npip3 install -U pyro-listener\n```\n\n### Community\n\n- Join the telegram channel: https://t.me/Y88F8\n\n### Examples\n- https://github.com/x72x/pyro-listener/tree/main/examples\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Pyrogram listener",
    "version": "2023.9.19",
    "project_urls": null,
    "split_keywords": [
        "python",
        "pyrogram",
        "telegram"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "453e6d7de4834c459f65ede38ec36e7f23d0f0bd83ec93eb5a68af527980c05b",
                "md5": "777176a83f45c2ccf20bb878d7d58fac",
                "sha256": "74d1829b4a3c63f36d1c5e9161bf281d8c7587ade36e88a667d7c2570655f285"
            },
            "downloads": -1,
            "filename": "pyro_listener-2023.9.19-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "777176a83f45c2ccf20bb878d7d58fac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.7",
            "size": 5374,
            "upload_time": "2023-09-19T14:24:11",
            "upload_time_iso_8601": "2023-09-19T14:24:11.921513Z",
            "url": "https://files.pythonhosted.org/packages/45/3e/6d7de4834c459f65ede38ec36e7f23d0f0bd83ec93eb5a68af527980c05b/pyro_listener-2023.9.19-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3671e45b3183c5dee146de642a26f0c49d2022778f6d92608f0e26d2b4090a62",
                "md5": "9f673e8ab0597e1f3100b35eb36caa83",
                "sha256": "58ae3d35f6d03e4f928612a0f8a7cd05069fa4fd9c402d096df53150aa3f9099"
            },
            "downloads": -1,
            "filename": "pyro-listener-2023.9.19.tar.gz",
            "has_sig": false,
            "md5_digest": "9f673e8ab0597e1f3100b35eb36caa83",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.7",
            "size": 5036,
            "upload_time": "2023-09-19T14:24:14",
            "upload_time_iso_8601": "2023-09-19T14:24:14.006897Z",
            "url": "https://files.pythonhosted.org/packages/36/71/e45b3183c5dee146de642a26f0c49d2022778f6d92608f0e26d2b4090a62/pyro-listener-2023.9.19.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-19 14:24:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pyro-listener"
}
        
Elapsed time: 0.11623s