Pyrogram listener
Examples
•
News
Pyrolistener
Message listener example
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
@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
@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
@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
@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
pip3 install -U pyro-listener
Community
- Join the telegram channel: https://t.me/Y88F8
Examples
Metadata
Release files for pyro-listener 2023.9.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyro-listener-2023.9.19.tar.gz | 5.0 kB | Without provenance | Details for pyro-listener-2023.9.19.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyro_listener-2023.9.19-py3-none-any.whl | Python 3 | none | any | Details for pyro_listener-2023.9.19-py3-none-any.whl |
Total release size: 10.4 kB
Release files / pyro-listener-2023.9.19.tar.gz
| Download URL | pyro-listener-2023.9.19.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58ae3d35f6d03e4f928612a0f8a7cd05069fa4fd9c402d096df53150aa3f9099
|
|
BLAKE2b-256 checksum How to use checksums |
3671e45b3183c5dee146de642a26f0c49d2022778f6d92608f0e26d2b4090a62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / pyro_listener-2023.9.19-py3-none-any.whl
| Download URL | pyro_listener-2023.9.19-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74d1829b4a3c63f36d1c5e9161bf281d8c7587ade36e88a667d7c2570655f285
|
|
BLAKE2b-256 checksum How to use checksums |
453e6d7de4834c459f65ede38ec36e7f23d0f0bd83ec93eb5a68af527980c05b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for pyro-listener 2023.9.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.