示例#1
0
文件: filters.py 项目: ezywebca/bot-2
 async def handle_twitch(self, message, extra):
     tosearch = str(message.system_content) + \
         str([e.to_dict() for e in message.embeds]) if not extra else extra
     twitch = findtwitch(tosearch)
     if twitch:
         if not message.author.permissions_in(
                 message.channel).manage_messages:
             try:
                 await message.delete()
             except Exception:
                 pass
             logch = self.bot.get_config(message.guild).get('log.action')
             if logch:
                 description = f'**Twitch link sent in** {message.channel.mention}'
                 if twitch in extra:
                     if twitch in str(message.system_content) + str(
                         [e.to_dict() for e in message.embeds]):
                         return
                     description = f'**Twitch link found in external content**'
                 embed = discord.Embed(color=message.author.color,
                                       timestamp=message.created_at,
                                       description=description)
                 embed.set_author(name=message.author,
                                  icon_url=str(
                                      message.author.avatar_url_as(
                                          static_format='png', size=2048)))
                 embed.add_field(
                     name='Link',
                     value=f'[{twitch}](https://twitch.tv/{twitch})',
                     inline=False)
                 embed.set_footer(text=f"Author ID: {message.author.id}")
                 try:
                     await logch.send(embed=embed)
                 except Exception:
                     pass
示例#2
0
 async def handle_twitch(self, message):
     twitch = findtwitch(message.system_content)
     if twitch:
         if not message.author.permissions_in(message.channel).manage_messages:
             if 'twitch' in self.bot.configs[message.guild.id].get('mod.linkfilter'):
                 try:
                     await message.delete()
                 except Exception:
                     pass
                 logch = self.bot.configs[message.guild.id].get('log.action')
                 if logch:
                     embed = discord.Embed(color=message.author.color, timestamp=message.created_at, description=f'**Twitch link sent in** {message.channel.mention}')
                     embed.set_author(name=message.author, icon_url=str(message.author.avatar_url_as(static_format='png', size=2048)))
                     embed.add_field(name='Link', value=f'[{twitch}](https://twitch.tv/{twitch})', inline=False)
                     embed.set_footer(text=f"Author ID: {message.author.id}")
                     try:
                         await logch.send(embed=embed)
                     except Exception:
                         pass