def purgecheck(m): content = m.content if include_embeds and m.embeds: content = m.content + \ str([self.get_embed_content(e) for e in m.embeds]) completed = [] if users: completed.append(m.author.id in users) if match: completed.append(match.lower() in content.lower()) if nomatch: completed.append(nomatch.lower() not in content.lower()) if startswith: completed.append(content.lower().startswith( startswith.lower())) if endswith: completed.append(content.lower().endswith(endswith.lower())) if attachments: completed.append(len(m.attachments) >= 1) if bot: completed.append(m.author.bot) elif bot is False: # not includes None meaning "not bot" would be triggered if not included completed.append(not m.author.bot) if invite: completed.append(findinvite(content)) if text is False: # same as bot completed.append(not m.content) return len([c for c in completed if not c]) == 0
async def handle_invite(self, message, extra): tosearch = str(message.system_content) + str([e.to_dict() for e in message.embeds]) if not extra else extra codes = findinvite(tosearch) invite = None for fullurl, code in codes: if fullurl in self.allowed_invites: continue if any(u in fullurl for u in ['h.inv.wtf', 'i.inv.wtf']) and self.bot.isadmin(message.author): continue if not message.author.permissions_in(message.channel).manage_messages: if 'discord' in self.bot.get_config(message.guild).get('mod.linkfilter'): try: invite = await self.bot.fetch_invite(url=code) if invite.guild.id != message.guild.id: await message.delete() except discord.NotFound: vanitydomains = ['oh-my-god.wtf', 'inv.wtf', 'floating-through.space', 'i-live-in.space', 'i-need-personal.space', 'get-out-of-my-parking.space'] if any(d in fullurl for d in vanitydomains): invite = await self.bot.get_vanity(code) if not invite or invite['gid'] != message.guild.id: try: await message.delete() except Exception: pass else: if 'dis.gd' not in fullurl: try: await message.delete() except Exception: pass except discord.Forbidden: pass logch = self.bot.get_config(message.guild).get('log.action') if logch: description = f'**Invite link sent in** {message.channel.mention}' if fullurl in extra: if fullurl in str(message.system_content) + str([e.to_dict() for e in message.embeds]): # Prevent logging inf also in content/embed continue description = f'**Invite 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='Invite Code', value=code, inline=False) if isinstance(invite, dict): invite = await self.bot.fetch_invite(url=invite['invite']) if isinstance(invite, discord.Invite): embed.add_field(name='Guild', value=f'{invite.guild.name}({invite.guild.id})', inline=False) embed.add_field(name='Channel', value=f'#{invite.channel.name}({invite.channel.id})', inline=False) embed.add_field(name='Members', value=f'{invite.approximate_member_count} ({invite.approximate_presence_count} active)', inline=False) embed.set_footer(text=f"Author ID: {message.author.id}") try: await logch.send(embed=embed) except Exception: pass
async def makeredirect(self, ctx, slug: str = None, url: str = None): if not ctx.guild.id in self.bot.premium_guilds: return await ctx.error( 'This feature is premium only! You can learn more at <https://gaminggeek.dev/premium>' ) if not slug: return await ctx.error('You must provide a slug!') if not url: return await ctx.error( 'You must provide a url or "delete" to delete an existing redirect!' ) if url.lower() in ['remove', 'delete', 'true', 'yeet', 'disable']: current = await self.bot.get_vanity(slug.lower()) if not current or 'uid' not in current: return await ctx.error('Redirect not found!') if current['uid'] != str(ctx.author.id): return await ctx.error( 'You can only delete your own redirects!') await self.delete(slug.lower()) return await ctx.success('Redirect deleted!') if 'https://' not in url: return await ctx.error('URL must include "https://"') if findinvite(url): return await ctx.error('Redirects cannot be used for invite links') if not re.fullmatch(r'[a-zA-Z0-9]+', slug): return await ctx.error( 'Redirect slugs can only contain characters A-Z0-9') if len(slug) < 3 or len(slug) > 20: return await ctx.error('The slug needs to be 3-20 characters!') query = 'SELECT * FROM vanity WHERE code=$1;' exists = await self.bot.db.fetch(query, slug.lower()) if exists: return await ctx.error('This slug is already in use!') redir = await self.create(slug.lower(), url, ctx.author.id) if redir: await ctx.success( f'Your redirect is https://inv.wtf/{slug.lower()}') author = str(ctx.author).replace('#', '%23') if not self.bot.dev: # TODO setup slack await pushover( f'{author} ({ctx.author.id}) has created the redirect `{slug}` for {url}', url=url, url_title='Check out redirect') else: await pushover( f'{author} ({ctx.author.id}) has created the redirect `{slug}` for {url}', url=url, url_title='Check out redirect') else: return await ctx.error('Something went wrong...')
def purgecheck(m): completed = [] if user: completed.append(m.author.id == user.id) if match: completed.append(match.lower() in m.content.lower()) if nomatch: completed.append(nomatch.lower() not in m.content.lower()) if startswith: completed.append(m.content.lower().startswith(startswith.lower())) if endswith: completed.append(m.content.lower().endswith(endswith.lower())) if attachments: completed.append(len(m.attachments) >= 1) if bot: completed.append(m.author.bot) elif bot is False: # not includes None meaning "not bot" would be triggered if not included completed.append(not m.author.bot) if invite: completed.append(findinvite(m.content)) if text is False: # same as bot completed.append(not m.content) return len([c for c in completed if not c]) == 0