# Botmom
Простая и многофункциональная библиотека для создания своих ботов для телеграмм
## Установка
Введите в терминал:
```bash
pip install botmom --upgrade --user
```
или запустите этот код:
```python
import os, sys
python = sys.executable
user = '--user' if 'venv' not in python and 'envs' not in python else ''
cmd = f'"{python}" -m pip install botmom --upgrade {user}'
os.system(cmd)
```
## Примеры
Простой echo-бот:
```python
from botmom import *
async def on_message(msg):
await msg.answer("Твоё сообщение: " + msg.text)
run_bot("TOKEN_FROM_BOTFATHER")
```
Простой работа с командами:
```python
from botmom import *
async def on_command_start(cmd):
await cmd.answer("Привет! \nДля помощи - напиши /help")
async def on_command_help(cmd):
await cmd.answer("Пока ничем не могу помочь :(")
run_bot("TOKEN_FROM_BOTFATHER")
```
Создание Inline-кнопок
```python
from botmom import *
async def on_command_start(cmd):
buttons = InlineButtons({"Да": "help_yes", "Нет": "help_no"})
await cmd.answer("Привет! Тебе помочь?", buttons)
async def on_button(callback):
if callback.data == "help_yes":
await callback.answer("Тогда слушай внимательно!")
elif callback.data == "help_no":
msg = await callback.answer("Ну и ладно")
await asyncio.sleep(3) # Вместо time.sleep(), время в секундах
await msg.delete() # Удалит сообщение "Ну и ладно"
run_bot("TOKEN_FROM_BOTFATHER")
```
Создание Reply-кнопок
```python
from botmom import *
states = dict()
async def on_command_start(cmd):
buttons = ReplyButtons(["Да", "Нет"])
await cmd.answer("Привет! Тебе помочь?", buttons)
states[cmd.chat_id] = "waiting"
async def on_message(msg):
if states[cmd.chat_id] == "waiting" and msg.text == "Да":
buttons = ReplyButtons(["Окей"])
await msg.answer("Тогда слушай внимательно!", buttons)
if states[cmd.chat_id] == "waiting" and msg.text == "Да":
buttons = ReplyButtons() # Удалить все кнопки
ok_msg = await msg.answer("Ну и ладно", buttons)
await asyncio.sleep(3) # Вместо time.sleep(), время в секундах
await ok_msg.delete() # Удалит сообщение "Ну и ладно"
run_bot("TOKEN_FROM_BOTFATHER")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Arsenii22/botmom",
"name": "botmom",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "telegram botmom bots chatbots",
"author": "Arsenii Misiurenko",
"author_email": "2028misyurenko.ad@student.letovo.ru",
"download_url": "https://files.pythonhosted.org/packages/c6/44/2eed7eb48c31339a6a5cf462e1ab13d5f7367b0b625d57cb4252dc645992/botmom-1.0.tar.gz",
"platform": null,
"description": "# Botmom\r\n\r\n\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0438 \u043c\u043d\u043e\u0433\u043e\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0431\u043e\u0442\u043e\u0432 \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\r\n\r\n\r\n## \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\r\n\r\n\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b:\r\n\r\n```bash\r\npip install botmom --upgrade --user\r\n```\r\n\r\n\u0438\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434:\r\n\r\n```python\r\nimport os, sys\r\n\r\npython = sys.executable\r\nuser = '--user' if 'venv' not in python and 'envs' not in python else ''\r\ncmd = f'\"{python}\" -m pip install botmom --upgrade {user}'\r\nos.system(cmd)\r\n```\r\n\r\n\r\n## \u041f\u0440\u0438\u043c\u0435\u0440\u044b\r\n\r\n\u041f\u0440\u043e\u0441\u0442\u043e\u0439 echo-\u0431\u043e\u0442:\r\n\r\n```python\r\nfrom botmom import *\r\n\r\nasync def on_message(msg):\r\n await msg.answer(\"\u0422\u0432\u043e\u0451 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435: \" + msg.text)\r\n\r\nrun_bot(\"TOKEN_FROM_BOTFATHER\")\r\n```\r\n\r\n\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438:\r\n\r\n```python\r\nfrom botmom import *\r\n\r\nasync def on_command_start(cmd):\r\n await cmd.answer(\"\u041f\u0440\u0438\u0432\u0435\u0442! \\n\u0414\u043b\u044f \u043f\u043e\u043c\u043e\u0449\u0438 - \u043d\u0430\u043f\u0438\u0448\u0438 /help\")\r\n\r\n\r\nasync def on_command_help(cmd):\r\n await cmd.answer(\"\u041f\u043e\u043a\u0430 \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u043c\u043e\u0447\u044c :(\")\r\n\r\n\r\nrun_bot(\"TOKEN_FROM_BOTFATHER\")\r\n```\r\n\r\n\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Inline-\u043a\u043d\u043e\u043f\u043e\u043a\r\n\r\n```python\r\nfrom botmom import *\r\n\r\nasync def on_command_start(cmd):\r\n buttons = InlineButtons({\"\u0414\u0430\": \"help_yes\", \"\u041d\u0435\u0442\": \"help_no\"})\r\n\r\n await cmd.answer(\"\u041f\u0440\u0438\u0432\u0435\u0442! \u0422\u0435\u0431\u0435 \u043f\u043e\u043c\u043e\u0447\u044c?\", buttons)\r\n\r\n\r\nasync def on_button(callback):\r\n if callback.data == \"help_yes\":\r\n await callback.answer(\"\u0422\u043e\u0433\u0434\u0430 \u0441\u043b\u0443\u0448\u0430\u0439 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e!\")\r\n\r\n elif callback.data == \"help_no\":\r\n msg = await callback.answer(\"\u041d\u0443 \u0438 \u043b\u0430\u0434\u043d\u043e\")\r\n \r\n await asyncio.sleep(3) # \u0412\u043c\u0435\u0441\u0442\u043e time.sleep(), \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445\r\n await msg.delete() # \u0423\u0434\u0430\u043b\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \"\u041d\u0443 \u0438 \u043b\u0430\u0434\u043d\u043e\"\r\n \r\n\r\nrun_bot(\"TOKEN_FROM_BOTFATHER\")\r\n```\r\n\r\n\r\n\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Reply-\u043a\u043d\u043e\u043f\u043e\u043a\r\n\r\n```python\r\nfrom botmom import *\r\n\r\nstates = dict()\r\n\r\nasync def on_command_start(cmd):\r\n buttons = ReplyButtons([\"\u0414\u0430\", \"\u041d\u0435\u0442\"])\r\n\r\n await cmd.answer(\"\u041f\u0440\u0438\u0432\u0435\u0442! \u0422\u0435\u0431\u0435 \u043f\u043e\u043c\u043e\u0447\u044c?\", buttons)\r\n states[cmd.chat_id] = \"waiting\"\r\n\r\n\r\nasync def on_message(msg):\r\n if states[cmd.chat_id] == \"waiting\" and msg.text == \"\u0414\u0430\":\r\n buttons = ReplyButtons([\"\u041e\u043a\u0435\u0439\"])\r\n\r\n await msg.answer(\"\u0422\u043e\u0433\u0434\u0430 \u0441\u043b\u0443\u0448\u0430\u0439 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e!\", buttons)\r\n\r\n if states[cmd.chat_id] == \"waiting\" and msg.text == \"\u0414\u0430\":\r\n buttons = ReplyButtons() # \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u043a\u043d\u043e\u043f\u043a\u0438\r\n\r\n ok_msg = await msg.answer(\"\u041d\u0443 \u0438 \u043b\u0430\u0434\u043d\u043e\", buttons)\r\n\r\n await asyncio.sleep(3) # \u0412\u043c\u0435\u0441\u0442\u043e time.sleep(), \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445\r\n await ok_msg.delete() # \u0423\u0434\u0430\u043b\u0438\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \"\u041d\u0443 \u0438 \u043b\u0430\u0434\u043d\u043e\"\r\n \r\n\r\nrun_bot(\"TOKEN_FROM_BOTFATHER\")\r\n```\r\n\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Easiest and most variable module for creating telegram bots",
"version": "1.0",
"project_urls": {
"GitHub": "https://github.com/Arsenii22/botmom",
"Homepage": "https://github.com/Arsenii22/botmom"
},
"split_keywords": [
"telegram",
"botmom",
"bots",
"chatbots"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c6442eed7eb48c31339a6a5cf462e1ab13d5f7367b0b625d57cb4252dc645992",
"md5": "56877fcc3ce9cec7d90276624f2a4829",
"sha256": "4e8aefa827cd5fa54896da0207ab634ad78e2ce44c52ff6930156e17908b4c9b"
},
"downloads": -1,
"filename": "botmom-1.0.tar.gz",
"has_sig": false,
"md5_digest": "56877fcc3ce9cec7d90276624f2a4829",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 4433,
"upload_time": "2024-04-17T09:36:14",
"upload_time_iso_8601": "2024-04-17T09:36:14.833056Z",
"url": "https://files.pythonhosted.org/packages/c6/44/2eed7eb48c31339a6a5cf462e1ab13d5f7367b0b625d57cb4252dc645992/botmom-1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-17 09:36:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Arsenii22",
"github_project": "botmom",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "botmom"
}