Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmrz/baymax
Simple telegram bot on top of Python asyncio
https://github.com/dmrz/baymax
asyncio bot python telegram
Last synced: 2 months ago
JSON representation
Simple telegram bot on top of Python asyncio
- Host: GitHub
- URL: https://github.com/dmrz/baymax
- Owner: dmrz
- License: mit
- Created: 2018-01-10T21:33:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-02-26T02:13:29.000Z (almost 4 years ago)
- Last Synced: 2024-11-15T17:50:40.147Z (3 months ago)
- Topics: asyncio, bot, python, telegram
- Language: Python
- Homepage:
- Size: 167 KB
- Stars: 30
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Baymax, a simple telegram bot framework on top of Python asyncio
Work in progress
### Requirements
* Python 3.6 or higher
### Installation
```bash
pip install baymax
```### Basic usage example
```python
from baymax.bot import Botbot = Bot('token')
@bot.on('/start')
async def start_handler(message):
await bot.reply(message, 'Welcome!')bot.run()
```### Middleware example
```python
@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
```python
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.