Installing
pip3 install -U tele-mod
Telemod
Message listener example
import asyncio
from telebot import async_telebot, types
from telemod import Listener
bot = async_telebot.AsyncTeleBot(token="")
loop = asyncio.get_event_loop()
listener = Listener(bot=bot, loop=loop)
@bot.message_handler(commands=["start"])
async def _(message: types.Message):
msg = await listener.listen_to(m=message, text="What's Your name?")
await bot.reply_to(msg, f"Your name is {msg.text}")
# to delete question message
# await bot.delete_message(chat_id=message.chat.id, message_id=msg.output.id)
async def main():
print((await bot.get_me()).first_name)
await bot.infinity_polling(skip_pending=True)
loop.run_until_complete(main())
CallbackQuery Listener Example
@bot.callback_query_handler(func = lambda query: True)
async def _(query: types.CallbackQuery):
if query.data == "name":
msg = await listener.listen_to(
query,
"What's your name?",
filters=["text"]
)
return await bot.reply_to(msg, f"Your name is {msg.text}")
Simple usage example
msg = await listener.listen(
chat_id=chat_id,
text="What's your name",
from_id=from_id,
filters=["text", "photo"]
)
print(msg)
Time out example
@bot.message_handler(commands=["start"])
async def start_handler(message: types.Message):
try:
msg = await listener.listen_to(message, "What's your name?", timeout=10)
except TimeOut:
msg = None
await bot.reply_to(message, "Time Out")
if msg:
return await bot.reply_to(msg, f"Hi {msg.text}")
Filters type example
@bot.message_handler(commands=["ask"], chat_types=["supergroup"])
async def _(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 bot.reply_to(msg, msg.text)
Community
- Join To Our Channel: https://t.me/Y88F8
Examples
Metadata
Release files for tele-mod 2.5
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 |
|---|---|---|---|---|
| tele-mod-2.5.tar.gz | 4.9 kB | Without provenance | Details for tele-mod-2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tele_mod-2.5-py3-none-any.whl | Python 3 | none | any | Details for tele_mod-2.5-py3-none-any.whl |
Total release size: 9.9 kB
Release files / tele-mod-2.5.tar.gz
| Download URL | tele-mod-2.5.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69c6a9b0dd9392c4d2524fd324bc8872db775085ebff0231c390f476f66def35
|
|
BLAKE2b-256 checksum How to use checksums |
63176ad814959a0c1949c58ce18c31a61a271c2bd524ffe942ed62415ae35550
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / tele_mod-2.5-py3-none-any.whl
| Download URL | tele_mod-2.5-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c53eea4010d22ea7f073091fadbaa611b8177e7b16fce50b8f0d4229a10e4b23
|
|
BLAKE2b-256 checksum How to use checksums |
35f7aaab98a6b3e7f7591eec606b34abe0e3ad3a4ec8e9c6b78961ac106ffa9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for tele-mod 2.5
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.