Skip to content

Commit

Permalink
Add missing intent and move events log autoban by scamming sites
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenChen committed Sep 4, 2021
1 parent 3f7d3ce commit ebaec93
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
53 changes: 32 additions & 21 deletions cogs/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ def highlight_matches(self, matches: List[re.Match], message: str) -> str:
channel_antispam = {}
help_notice_anti_repeat = []

async def userbot_yeeter_pop(self, message):
await asyncio.sleep(20)
self.userbot_yeeter[message.author.id].remove(message.channel)
try:
if len(self.userbot_yeeter[message.author.id]) == 0:
self.userbot_yeeter.pop(message.author.id)
except KeyError:
pass

async def scan_message(self, message, is_edit=False):
random.seed(message.id)
embed = discord.Embed(color=utils.gen_color(message.id))
Expand Down Expand Up @@ -253,6 +262,29 @@ async def scan_message(self, message, is_edit=False):
if contains_video and message.channel in self.bot.assistance_channels:
await self.bot.channels['message-logs'].send(
f"▶️ **Video posted**: {message.author.mention} posted a video in {message.channel.mention}\n------------------\n{message.clean_content}")

if contains_scamming_site_levenshtein or contains_scamming_site:
if message.author.id not in self.userbot_yeeter:
self.userbot_yeeter[message.author.id] = []
if message.channel not in self.userbot_yeeter[message.author.id]:
self.userbot_yeeter[message.author.id].append(message.channel)
if len(self.userbot_yeeter[message.author.id]) == 2:
msg = ("You have been banned from Nintendo Homebrew for linking scamming sites in multiple channels. "
"If you think this is a mistake contact ❅FrozenFire❆#0700 on discord or send a email to [email protected]")
await utils.send_dm_message(message.author, msg)
self.bot.actions.append('wb:' + str(message.author.id))
await message.author.ban(reason="Linking scamming links in multiple channels.")
log_msg = f"⛔ **Auto-ban**: {message.author.mention} banned for spamming scamming sites | {message.author}\n🗓 __Creation__: {message.author.created_at}\n🏷 __User ID__: {message.author.id}"
await self.bot.channels['mod-logs'].send(log_msg)
await self.bot.channels['mods'].send(log_msg)
try:
await message.delete()
except discord.errors.NotFound:
pass
return
else:
self.bot.loop.create_task(self.userbot_yeeter_pop(message))

if contains_scamming_site:
embed.description = self.highlight_matches(contains_scamming_site, msg)
try:
Expand Down Expand Up @@ -319,27 +351,6 @@ async def scan_message(self, message, is_edit=False):
await crud.add_permanent_role(message.author.id, self.bot.roles['Probation'].id)
await message.author.add_roles(self.bot.roles['Probation'])

if contains_scamming_site_levenshtein or contains_scamming_site:
if message.author.id not in self.userbot_yeeter:
self.userbot_yeeter[message.author.id] = []
if message.channel in self.userbot_yeeter[message.author.id]:
return
self.userbot_yeeter[message.author.id].append(message.channel)
if len(self.userbot_yeeter[message.author.id]) == 2:
msg = ("You have been banned from Nintendo Homebrew for linking scamming sites in multiple channels. "
"If you think this is a mistake contact ❅FrozenFire❆#0700 on discord or send a email to [email protected]")
await utils.send_dm_message(message.author, msg)
await message.author.ban(reason="Linking scamming links in multiple channels.")
log_msg = f"🔇 **Auto-banned**: {message.author.mention} banned for spamming scamming sites| {message.author}\n🗓 __Creation__: {message.author.created_at}\n🏷 __User ID__: {message.author.id}"
await self.bot.channels['mod-logs'].send(log_msg)
await asyncio.sleep(20)
self.userbot_yeeter[message.author.id].remove(message.channel)
try:
if len(self.userbot_yeeter[message.author.id]) == 0:
self.userbot_yeeter.pop(message.author.id)
except KeyError:
pass

async def user_spam_check(self, message):
if message.author.id not in self.user_antispam:
self.user_antispam[message.author.id] = []
Expand Down
2 changes: 1 addition & 1 deletion kurisu.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Kurisu(commands.Bot):

def __init__(self, command_prefix, description, commit, branch):

intents = discord.Intents(guilds=True, members=True, messages=True, reactions=True)
intents = discord.Intents(guilds=True, members=True, messages=True, reactions=True, bans=True)
allowed_mentions = discord.AllowedMentions(everyone=False, roles=False)
super().__init__(
command_prefix=command_prefix,
Expand Down

0 comments on commit ebaec93

Please sign in to comment.