async def webhook(keyword_content, send_type, is_separate):
    if not is_separate:
        temp = bot.log_conf['webhook_url'].split('/')
    else:
        temp = bot.log_conf['webhook_url2'].split('/')
    channel = temp[len(temp) - 2]
    token = temp[len(temp) - 1]
    webhook_class = Webhook(bot)
    request_webhook = webhook_class.request_webhook
    if send_type.startswith('embed'):
        if 'ping' in send_type:
            await request_webhook('/{}/{}'.format(channel, token),
                                  embeds=[keyword_content.to_dict()],
                                  content=bot.user.mention)
        else:
            await request_webhook('/{}/{}'.format(channel, token),
                                  embeds=[keyword_content.to_dict()],
                                  content=None)
    else:
        if 'ping' in send_type:
            await request_webhook('/{}/{}'.format(channel, token),
                                  content=keyword_content + '\n' +
                                  bot.user.mention,
                                  embeds=None)
        else:
            await request_webhook('/{}/{}'.format(channel, token),
                                  content=keyword_content,
                                  embeds=None)
示例#2
0
 async def webhook(self, entry, send_type):
     temp = self.bot.log_conf['webhook_url'].split('/')
     channel = temp[len(temp) - 2]
     token = temp[len(temp) - 1]
     webhook_class = Webhook(self.bot)
     request_webhook = webhook_class.request_webhook
     em = discord.Embed(title='Timer Alert', color=0x4e42f4, description='Timer for item: **%s** just ran out.' % entry)
     if 'ping' in send_type:
         await request_webhook('/{}/{}'.format(channel, token), embeds=[em.to_dict()], content=self.bot.user.mention)
     else:
         await request_webhook('/{}/{}'.format(channel, token), content=None, embeds=[em.to_dict()])