Yandex Messenger Bot API library
Obtaining Messenger bot token: [link](https://yandex.ru/support/yandex-360/business/admin/ru/bot-platform.html#bot-create)
### Update 0.0.4
Added logger support.
Create bot instance with `log_level=logging.DEBUG` argument for debug output. By default log level is INFO.
```yb = MessengerBot('bot_token', log_level=logging.DEBUG)```
### Update 0.0.3
Usage:
```pip install yambot-client```
```python
# Add handlers to MessengerBot
# Supported handlers: text, command, button, regex, any
from yambot import MessengerBot
yb = MessengerBot('bot_token')
# Add command handler ex. when user sends /my_command
@yb.add_handler(command='/my_command')
def my_handler1(update):
yb.send_message('test1', update)
# Add text handler ex. when user sends some_text
@yb.add_handler(text='some_text')
def my_handler2(update):
yb.send_message('test2', update)
# Add button handler. Button must have callback_data with 'cmd': '/my_button' JSON object
# For more details about CallbackData see API description: https://yandex.ru/dev/messenger/doc/ru/data-types#button
@yb.add_handler(button='/my_button')
def my_handler3(update):
yb.send_message('test3', update)
# Add regex handler. Provide regular expression that will be tested against user text message
@yb.add_handler(regex='\d{5}')
def my_handler3(update):
yb.send_message('test4', update)
# Handler that will be applied when no other handlers match
@yb.add_handler(any=True)
def process_any(update):
yb.send_message('Unknown text', update)
```
Available Bot methods:
```python
# Send text message. If update has chat or thread id message will be sent to chat or thread
# Otherwise message will be sent directly to user
yb.send_message('text', update)
# Send image. image_data can be either ASCII string or bytes object
yb.send_image(image_data, update)
# Send buttons. buttons must be a list of Button objects
yb.send_inline_keyboard(buttons, update)
```
Button example for `send_inline_keyboard()`:
```python
button1 = {'text': 'Button 1', 'callback_data': {'cmd': '/button_1'}}
button2 = {'text': 'Button 2', 'callback_data': {'cmd': '/button_2'}}
buttons = [button1, button2]
```
See example: [link](https://github.com/abugrin/yambot/blob/master/example.py)
Raw data
{
"_id": null,
"home_page": "https://github.com/abugrin/yambot",
"name": "yambot-client",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "python yandex.messenger api-client",
"author": "Anton Bugrin",
"author_email": "abugrin@yandex.ru",
"download_url": "https://files.pythonhosted.org/packages/43/3b/d5947fda0d2fe33d286207b8d860b016c61412945a6711731d075f788a1a/yambot_client-0.0.4.tar.gz",
"platform": null,
"description": "Yandex Messenger Bot API library\r\n\r\nObtaining Messenger bot token: [link](https://yandex.ru/support/yandex-360/business/admin/ru/bot-platform.html#bot-create) \r\n\r\n### Update 0.0.4\r\nAdded logger support.\r\nCreate bot instance with `log_level=logging.DEBUG` argument for debug output. By default log level is INFO. \r\n```yb = MessengerBot('bot_token', log_level=logging.DEBUG)```\r\n\r\n### Update 0.0.3\r\n\r\nUsage: \r\n```pip install yambot-client```\r\n\r\n```python\r\n# Add handlers to MessengerBot\r\n# Supported handlers: text, command, button, regex, any\r\n\r\nfrom yambot import MessengerBot\r\n\r\nyb = MessengerBot('bot_token')\r\n\r\n# Add command handler ex. when user sends /my_command\r\n@yb.add_handler(command='/my_command')\r\ndef my_handler1(update):\r\n yb.send_message('test1', update)\r\n\r\n# Add text handler ex. when user sends some_text\r\n@yb.add_handler(text='some_text')\r\ndef my_handler2(update):\r\n yb.send_message('test2', update)\r\n\r\n# Add button handler. Button must have callback_data with 'cmd': '/my_button' JSON object\r\n# For more details about CallbackData see API description: https://yandex.ru/dev/messenger/doc/ru/data-types#button \r\n@yb.add_handler(button='/my_button')\r\ndef my_handler3(update):\r\n yb.send_message('test3', update)\r\n\r\n# Add regex handler. Provide regular expression that will be tested against user text message \r\n@yb.add_handler(regex='\\d{5}')\r\ndef my_handler3(update):\r\n yb.send_message('test4', update)\r\n\r\n# Handler that will be applied when no other handlers match\r\n@yb.add_handler(any=True)\r\ndef process_any(update):\r\n yb.send_message('Unknown text', update)\r\n\r\n\r\n```\r\n\r\nAvailable Bot methods:\r\n\r\n```python\r\n# Send text message. If update has chat or thread id message will be sent to chat or thread\r\n# Otherwise message will be sent directly to user\r\nyb.send_message('text', update)\r\n\r\n# Send image. image_data can be either ASCII string or bytes object\r\nyb.send_image(image_data, update)\r\n\r\n# Send buttons. buttons must be a list of Button objects\r\nyb.send_inline_keyboard(buttons, update)\r\n\r\n```\r\n\r\nButton example for `send_inline_keyboard()`:\r\n```python\r\nbutton1 = {'text': 'Button 1', 'callback_data': {'cmd': '/button_1'}}\r\nbutton2 = {'text': 'Button 2', 'callback_data': {'cmd': '/button_2'}}\r\n\r\nbuttons = [button1, button2]\r\n```\r\n\r\nSee example: [link](https://github.com/abugrin/yambot/blob/master/example.py)\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Client for Yandex Messenger Bot API",
"version": "0.0.4",
"project_urls": {
"Homepage": "https://github.com/abugrin/yambot"
},
"split_keywords": [
"python",
"yandex.messenger",
"api-client"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1b7f73e95e9353bac4d4f11e6ba3422dfac3f7ab836c42b2f59197c65ccb5a27",
"md5": "68d87c9b17af10503f7c666590357e4a",
"sha256": "eb1bed4884bc78d379c0532acccdf6a78afefca180eb2ae885b43cd793ffbcdb"
},
"downloads": -1,
"filename": "yambot_client-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "68d87c9b17af10503f7c666590357e4a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 5485,
"upload_time": "2024-10-08T07:55:10",
"upload_time_iso_8601": "2024-10-08T07:55:10.712605Z",
"url": "https://files.pythonhosted.org/packages/1b/7f/73e95e9353bac4d4f11e6ba3422dfac3f7ab836c42b2f59197c65ccb5a27/yambot_client-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "433bd5947fda0d2fe33d286207b8d860b016c61412945a6711731d075f788a1a",
"md5": "03c0b0ede8edd0db067749c269848295",
"sha256": "68448397e0d797a6ef218f4072439c1c481b0da1ca5142158bb4b7144cc75af6"
},
"downloads": -1,
"filename": "yambot_client-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "03c0b0ede8edd0db067749c269848295",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4783,
"upload_time": "2024-10-08T07:55:12",
"upload_time_iso_8601": "2024-10-08T07:55:12.611919Z",
"url": "https://files.pythonhosted.org/packages/43/3b/d5947fda0d2fe33d286207b8d860b016c61412945a6711731d075f788a1a/yambot_client-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-08 07:55:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "abugrin",
"github_project": "yambot",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "python-dotenv",
"specs": [
[
"~=",
"1.0.1"
]
]
},
{
"name": "requests",
"specs": [
[
"~=",
"2.32.3"
]
]
},
{
"name": "setuptools",
"specs": [
[
"~=",
"74.1.2"
]
]
}
],
"lcname": "yambot-client"
}