具有两个IO后端的SAN IO Telegram API
siotelegram的Python项目详细描述
#telegram api的Sans-io实现
Tiny telegram bot api包装库。
##功能
*同时支持这两种功能,同步和异步处理io的方法。
*简单如电报api。
*`snake_case`api转换为电报'camelCase`.
*通过'get_updates'方法为您处理的轮询'offset'。
*自动处理请求之间的超时(通过'delay'仅限关键字的参数)。
*使用任何需要的io后端。
实现
[sans io](http://sans-io.readthedocs.io/)基于生成器的实现
,用于简化流和保持状态。` siohttelegram的io后端基于:
*请求
*aiohhttp
*安装
*同步:`python-m pip install siotelegram[requests]`
*异步:`python-m pip install siohttelegram[aiohhtttp]`
``公共
br/>
导入sioTelegram
令牌=“token”
def requests_example():
api=siotegrampi.requeststelegrampi(token,timeout=10)
response=api.get_updates()
print(response)
async def aiohttp_example():
async with siotegrampe.aiohttptelegrampi(token,timeout=10)as api:
response=awit api.get_updates()
打印(响应)
发送文件
`` python
导入siotegram
api=sioTelegramapi.requeststelegramapi(令牌,超时=10)
name=“capybara.jpg”
api.send_photo(chat_id=chat_id,caption=“地狱世界!”,文件名(photo=open(,“rb”))
,文件(photo=f))
````
Tiny telegram bot api包装库。
##功能
*同时支持这两种功能,同步和异步处理io的方法。
*简单如电报api。
*`snake_case`api转换为电报'camelCase`.
*通过'get_updates'方法为您处理的轮询'offset'。
*自动处理请求之间的超时(通过'delay'仅限关键字的参数)。
*使用任何需要的io后端。
实现
[sans io](http://sans-io.readthedocs.io/)基于生成器的实现
,用于简化流和保持状态。` siohttelegram的io后端基于:
*请求
*aiohhttp
*安装
*同步:`python-m pip install siotelegram[requests]`
*异步:`python-m pip install siohttelegram[aiohhtttp]`
``公共
br/>
导入sioTelegram
令牌=“token”
def requests_example():
api=siotegrampi.requeststelegrampi(token,timeout=10)
response=api.get_updates()
print(response)
async def aiohttp_example():
async with siotegrampe.aiohttptelegrampi(token,timeout=10)as api:
response=awit api.get_updates()
打印(响应)
发送文件
`` python
导入siotegram
api=sioTelegramapi.requeststelegramapi(令牌,超时=10)
name=“capybara.jpg”
api.send_photo(chat_id=chat_id,caption=“地狱世界!”,文件名(photo=open(,“rb”))
,文件(photo=f))
````