基于python asyncio的简单telegram bot框架
baymax的Python项目详细描述
baymax,一个简单的基于python asyncio的telegram bot框架
进行中的工作
要求
- python 3.7或更高版本
安装
pip install baymax
基本用法示例
frombaymax.botimportBotbot=Bot('token')@bot.on('/start')asyncdefstart_handler(message):awaitbot.reply(message,'Welcome!')bot.run()
中间件示例
@bot.middlewareasyncdefmessage_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.
运行测试
git clone git@github.com:dmrz/baymax.git pip install -e . pip install -r requirements-test.txt pytest