Skip to main content

A simple telegram bot framework on top of Python asyncio

Project description

Baymax, a simple telegram bot framework on top of Python asyncio

Work in progress

Requirements

  • Python 3.7 or higher

Installation

pip install baymax

Basic usage example

from baymax.bot import Bot

bot = Bot('token')

@bot.on('/start')
async def start_handler(message):
    await bot.reply(message, 'Welcome!')

bot.run()

Middleware example

@bot.middleware
async def message_logging_middleware(raw_update):
    bot.logger.info('New update received: %s', raw_update['update_id'])

NOTE: All middleware functions should be coroutines for now, even if they do not have asynchronous actions.

Reply keyboard markup example

from baymax.markups import KeyboardButton, ReplyKeyboardMarkup

@bot.on('/rate')
async def rate_handler(message):
    await bot.reply(message, 'Rate me', reply_markup=ReplyKeyboardMarkup(
        [
            [
                KeyboardButton('⭐️'),
                KeyboardButton('⭐️⭐️'),
                KeyboardButton('⭐️⭐️⭐️')
            ]
        ], resize_keyboard=True, one_time_keyboard=True))

NOTE: Reply markup API / objects will be changing, they are far from good now.

Running tests

git clone git@github.com:dmrz/baymax.git
pip install -e .
pip install -r requirements-test.txt
pytest

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

baymax-0.0.5-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file baymax-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: baymax-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for baymax-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 afaac70735bf2d358609c74ca97d704814b27ee7913d7c798ebd2f92ee303113
MD5 95af53b08d263c34d553023ee32f1f49
BLAKE2b-256 c6c2b826bf0a9429c6cf9811fa777abda82daf48103b03205a1f76afdfcaf1b0

See more details on using hashes here.

Supported by

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