discordban.py 文件源码

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

项目:B3DiscordPlugin 作者: efinst0rm 项目源码 文件源码
def discordEmbeddedPush(self, embed):
        """
        Send embedded message to discord bot huehue
        """
        data = json.dumps({"embeds": [embed]})
        req = urllib2.Request(self._discordWebhookUrl, data, {
            'Content-Type': 'application/json',
            "User-Agent": "B3DiscordbanPlugin/1.1" #Is that a real User-Agent? Nope but who cares.
        })

        # Final magic happens here, we will never get an error ofcourse ;)
        try:
            urllib2.urlopen(req)
        except urllib2.HTTPError as ex:
            self.debug("Cannot push data to Discord. is your webhook url right?")
            self.debug("Data: %s\nCode: %s\nRead: %s" % (data, ex.code, ex.read()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号