Name | tele-mod JSON |
Version |
2.5
JSON |
| download |
home_page | |
Summary | Telebot listener |
upload_time | 2023-09-22 22:46:10 |
maintainer | |
docs_url | None |
author | ZAID |
requires_python | ~=3.6 |
license | |
keywords |
python
pytelegrambotapi
telegram
telebot
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
## Installing
```bash
pip3 install -U tele-mod
```
## Telemod
> Message listener example
```python
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
```python
@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
```python
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
```python
@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
```python
@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
- https://github.com/x72x/tele-mod/tree/main/examples
Raw data
{
"_id": null,
"home_page": "",
"name": "tele-mod",
"maintainer": "",
"docs_url": null,
"requires_python": "~=3.6",
"maintainer_email": "",
"keywords": "python,pytelegrambotapi,telegram,telebot",
"author": "ZAID",
"author_email": "y8838@hotmail.com",
"download_url": "https://files.pythonhosted.org/packages/63/17/6ad814959a0c1949c58ce18c31a61a271c2bd524ffe942ed62415ae35550/tele-mod-2.5.tar.gz",
"platform": null,
"description": "\r\n## Installing\r\n\r\n```bash\r\n\r\npip3 install -U tele-mod\r\n\r\n```\r\n\r\n\r\n\r\n## Telemod\r\n\r\n> Message listener example\r\n\r\n\r\n\r\n```python\r\n\r\nimport asyncio\r\n\r\nfrom telebot import async_telebot, types\r\n\r\nfrom telemod import Listener\r\n\r\n\r\n\r\nbot = async_telebot.AsyncTeleBot(token=\"\")\r\n\r\nloop = asyncio.get_event_loop()\r\n\r\n\r\n\r\nlistener = Listener(bot=bot, loop=loop)\r\n\r\n\r\n\r\n@bot.message_handler(commands=[\"start\"])\r\n\r\nasync def _(message: types.Message):\r\n\r\n msg = await listener.listen_to(m=message, text=\"What's Your name?\")\r\n\r\n await bot.reply_to(msg, f\"Your name is {msg.text}\")\r\n\r\n # to delete question message\r\n\r\n # await bot.delete_message(chat_id=message.chat.id, message_id=msg.output.id)\r\n\r\n\r\n\r\nasync def main():\r\n\r\n print((await bot.get_me()).first_name)\r\n\r\n await bot.infinity_polling(skip_pending=True)\r\n\r\n\r\n\r\nloop.run_until_complete(main())\r\n\r\n```\r\n\r\n\r\n\r\n> CallbackQuery Listener Example\r\n\r\n\r\n\r\n```python\r\n\r\n@bot.callback_query_handler(func = lambda query: True)\r\n\r\nasync def _(query: types.CallbackQuery):\r\n\r\n if query.data == \"name\":\r\n\r\n msg = await listener.listen_to(\r\n\r\n query,\r\n\r\n \"What's your name?\",\r\n\r\n filters=[\"text\"]\r\n\r\n )\r\n\r\n return await bot.reply_to(msg, f\"Your name is {msg.text}\")\r\n\r\n```\r\n\r\n\r\n\r\n> Simple usage example\r\n\r\n\r\n\r\n```python\r\n\r\nmsg = await listener.listen(\r\n\r\n chat_id=chat_id,\r\n\r\n text=\"What's your name\",\r\n\r\n from_id=from_id,\r\n\r\n filters=[\"text\", \"photo\"]\r\n\r\n)\r\n\r\nprint(msg)\r\n\r\n```\r\n\r\n\r\n\r\n> Time out example\r\n\r\n\r\n\r\n```python\r\n\r\n@bot.message_handler(commands=[\"start\"])\r\n\r\nasync def start_handler(message: types.Message):\r\n\r\n try:\r\n\r\n msg = await listener.listen_to(message, \"What's your name?\", timeout=10)\r\n\r\n except TimeOut:\r\n\r\n msg = None\r\n\r\n await bot.reply_to(message, \"Time Out\")\r\n\r\n if msg:\r\n\r\n return await bot.reply_to(msg, f\"Hi {msg.text}\")\r\n\r\n```\r\n\r\n\r\n\r\n> Filters type example\r\n\r\n\r\n\r\n```python\r\n\r\n@bot.message_handler(commands=[\"ask\"], chat_types=[\"supergroup\"])\r\n\r\nasync def _(message: types.Message):\r\n\r\n msg = await listener.listen(\r\n\r\n chat_id=message.chat.id,\r\n\r\n text=\"What's your name\",\r\n\r\n filters=[\"sender_chat\", \"text\"],\r\n\r\n filters_type=2\r\n\r\n ) # will only listen to an message has \"sender_chat\" and \"text\" attribute\r\n\r\n msg = await listener.listen(\r\n\r\n chat_id=message.chat.id,\r\n\r\n text=\"What's your name\",\r\n\r\n filters=[\"sender_chat\", \"text\"],\r\n\r\n filters_type=1\r\n\r\n ) # will listen to any messgae has \"sender_chat\" or \"text\" attribute\r\n\r\n return await bot.reply_to(msg, msg.text)\r\n\r\n```\r\n\r\n\r\n\r\n## Community\r\n\r\n- Join To Our Channel: https://t.me/Y88F8\r\n\r\n\r\n\r\n## Examples\r\n\r\n- https://github.com/x72x/tele-mod/tree/main/examples\r\n\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Telebot listener",
"version": "2.5",
"project_urls": null,
"split_keywords": [
"python",
"pytelegrambotapi",
"telegram",
"telebot"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "35f7aaab98a6b3e7f7591eec606b34abe0e3ad3a4ec8e9c6b78961ac106ffa9d",
"md5": "c07ce050bde93cca7407671c8ebb282e",
"sha256": "c53eea4010d22ea7f073091fadbaa611b8177e7b16fce50b8f0d4229a10e4b23"
},
"downloads": -1,
"filename": "tele_mod-2.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c07ce050bde93cca7407671c8ebb282e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.6",
"size": 4919,
"upload_time": "2023-09-22T22:46:08",
"upload_time_iso_8601": "2023-09-22T22:46:08.746464Z",
"url": "https://files.pythonhosted.org/packages/35/f7/aaab98a6b3e7f7591eec606b34abe0e3ad3a4ec8e9c6b78961ac106ffa9d/tele_mod-2.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "63176ad814959a0c1949c58ce18c31a61a271c2bd524ffe942ed62415ae35550",
"md5": "e96b04b6698d7dd70997a52e5df661de",
"sha256": "69c6a9b0dd9392c4d2524fd324bc8872db775085ebff0231c390f476f66def35"
},
"downloads": -1,
"filename": "tele-mod-2.5.tar.gz",
"has_sig": false,
"md5_digest": "e96b04b6698d7dd70997a52e5df661de",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.6",
"size": 4933,
"upload_time": "2023-09-22T22:46:10",
"upload_time_iso_8601": "2023-09-22T22:46:10.741719Z",
"url": "https://files.pythonhosted.org/packages/63/17/6ad814959a0c1949c58ce18c31a61a271c2bd524ffe942ed62415ae35550/tele-mod-2.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-22 22:46:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "tele-mod"
}