Python asyncio 之上的一个简单的电报机器人框架
项目描述
Baymax,一个基于 Python asyncio 的简单电报机器人框架
工作正在进行中
要求
Python 3.7 或更高版本
安装
pip install baymax
基本使用示例
from baymax.bot import Bot
bot = Bot('token')
@bot.on('/start')
async def start_handler(message):
await bot.reply(message, 'Welcome!')
bot.run()
中间件示例
@bot.middleware
async def message_logging_middleware(raw_update):
bot.logger.info('New update received: %s', raw_update['update_id'])
注意:所有中间件函数现在都应该是协程,即使它们没有异步操作。
运行测试
git clone git@github.com:dmrz/baymax.git
pip install -e .
pip install -r requirements-test.txt
pytest