非正式电报bot api库和客户端
twx.botapi的Python项目详细描述
twx.botapi
twx.bot api:非正式电报bot api库和客户端
- | - |
---|---|
contributions | Please join https://github.com/datamachine/twx.botapi |
issues | Please use https://github.com/datamachine/twx.botapi/issues |
Python version supported | 2.7, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6 |
twx.bot api是用于电报bot api的python接口。它支持 进行同步和异步调用并将响应转换为 可用的本机python对象。
对mtproto api的支持正在进行中,但现在被认为是pre-alpha。
支架
您可以在以下位置加入我们的支持聊天:https://telegram.me/twxapi
安装
对于稳定:
pip install twx.botapi
对于dev:
pip install -i https://testpypi.python.org/pypi twx.botapi
文档
文档可以在http://pythonhosted.org/twx.botapi/
快速启动
fromtwx.botapiimportTelegramBot,ReplyKeyboardMarkup"""Setup the bot"""bot=TelegramBot('<API TOKEN>')bot.update_bot_info().wait()print(bot.username)"""Send a message to a user"""user_id=int(<someuserid>)result=bot.send_message(user_id,'test message body').wait()print(result)"""Get updates sent to the bot"""updates=bot.get_updates().wait()forupdateinupdates:print(update)"""Use a custom keyboard"""keyboard=[['7','8','9'],['4','5','6'],['1','2','3'],['0']]reply_markup=ReplyKeyboardMarkup.create(keyboard)bot.send_message(user_id,'please enter a number',reply_markup=reply_markup).wait()