Skip to main content

Client for Yandex Messenger Bot API

Project description

Yandex Messenger Bot API library

Obtaining Messenger bot token: link

Usage: pip install yambot-client

# 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:

# 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)

See example: link

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yambot_client-0.0.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yambot_client-0.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file yambot_client-0.0.3.tar.gz.

File metadata

  • Download URL: yambot_client-0.0.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for yambot_client-0.0.3.tar.gz
Algorithm Hash digest
SHA256 099dec1ac9d26121deef521fe355d77c4a5d8e86746f32f6e739de18c360616a
MD5 d8b9ab9028120a56bb58afdb57d31524
BLAKE2b-256 c07af8ca72ba6ff61486123cd80654edd3522017be35231460a4855d79edf6e1

See more details on using hashes here.

File details

Details for the file yambot_client-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: yambot_client-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for yambot_client-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6497f7357ae74db820e622f8f1c671f31c6a091ddfb5fefd1fd04f78172bc5e5
MD5 4af08b34a5945e4532cf02e393ce8d72
BLAKE2b-256 5440af4fcee73f8e7853894015153597b852ae87c18c965697f85af6d8e35829

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page