松弛API客户端
slacker的Python项目详细描述
关于
slacker是Slack API的全功能python接口。
安装
$ pip install slacker
示例
fromslackerimportSlackerslack=Slacker('<your-slack-api-token-goes-here>')# Send a message to #general channelslack.chat.post_message('#general','Hello fellow slackers!')# Get users listresponse=slack.users.list()users=response.body['members']# Upload a fileslack.files.upload('hello.txt')# If you need to proxy the requestsproxy_endpoint='http://myproxy:3128'slack=Slacker('<your-slack-api-token-goes-here>',http_proxy=proxy_endpoint,https_proxy=proxy_endpoint)# Advanced: Use `request.Session` for connection pooling (reuse)fromrequests.sessionsimportSessionwithSession()assession:slack=Slacker(token,session=session)slack.chat.post_message('#general','All these requests')slack.chat.post_message('#general','go through')slack.chat.post_message('#general','a single https connection')