pokeslack.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:PokemonGo-SlackBot 作者: rubenmak 项目源码 文件源码
def send_to_slack(text, username, icon_emoji, webhook):
    values = {'payload': '{"username": "' + username + '", '
                                        '"icon_emoji": "' + icon_emoji + '", '
                                        '"text": "' + text + '"}'
                             }
    str_values = {}
    for k, v in values.items():
        str_values[k] = unicode(v).encode('utf-8')
    data = urllib.urlencode(str_values)

    h = httplib.HTTPSConnection('hooks.slack.com')
    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

    h.request('POST', webhook, data, headers)
    r = h.getresponse()
    # ack = r.read()
    # print data
    # print ack
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号