diff --git a/README.md b/README.md index c9a2572..9f381c4 100755 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ All Robocop features are now supported. Main goal of this project is to get Robocop functionality done, secondary goal is adding new features. The following entries are secondary, less "urgent" goals: - [x] Better security, better checks and better guild whitelisting +- [ ] Purge: On purge, send logs in form of txt file to server logs - [ ] New verification feature: Using log module from akbbot for logging attempts and removing old attempts - [ ] New moderation feature: watch-unwatch (using log module from akbbot) - [ ] New feature: Modmail diff --git a/Robocop.py b/Robocop.py index a8cc43f..667f014 100755 --- a/Robocop.py +++ b/Robocop.py @@ -97,7 +97,8 @@ async def on_ready(): data_files = [discord.File(fpath) for fpath in wanted_jsons] await bot.botlog_channel.send(msg, files=data_files) - activity = discord.Activity(name=game_name, type=discord.ActivityType.listening) + activity = discord.Activity(name=game_name, + type=discord.ActivityType.listening) await bot.change_presence(activity=activity) diff --git a/cogs/links.py b/cogs/links.py index ed3f3d8..23e3ed1 100644 --- a/cogs/links.py +++ b/cogs/links.py @@ -32,9 +32,11 @@ class Links: @commands.command(hidden=True, aliases=["guides"]) async def guide(self, ctx): """Link to the guide(s)""" - await ctx.send("*AtlasNX's Guide:* https://guide.teamatlasnx.com\n" - "*Noirscape's Guide:* http://switchguide.xyz/\n" - "*Pegaswitch Guide:* https://switch.hacks.guide/") + await ctx.send("Nintendo Homebrew's Guide: " + "\n" + "Noirscape's Guide: \n" + "Pegaswitch Guide: " + "(outdated for anything but Pegaswitch)") def setup(bot): diff --git a/cogs/lockdown.py b/cogs/lockdown.py index 81257b0..6f8ac34 100644 --- a/cogs/lockdown.py +++ b/cogs/lockdown.py @@ -50,8 +50,9 @@ class Lockdown: "disciplinary actions." await ctx.send(public_msg) + safe_name = await commands.clean_content().convert(ctx, str(ctx.author)) msg = f"🔒 **Lockdown**: {ctx.channel.mention} by {ctx.author.mention} "\ - f"| {self.bot.escape_message(ctx.author)}" + f"| {safe_name}" await log_channel.send(msg) @commands.guild_only() @@ -77,9 +78,10 @@ class Lockdown: send_messages=True, reason=str(ctx.author)) + safe_name = await commands.clean_content().convert(ctx, str(ctx.author)) await ctx.send("🔓 Channel unlocked.") msg = f"🔓 **Unlock**: {ctx.channel.mention} by {ctx.author.mention} "\ - f"| {self.bot.escape_message(ctx.author)}" + f"| {safe_name}" await log_channel.send(msg) diff --git a/cogs/meme.py b/cogs/meme.py index 2ac056b..d5144ef 100644 --- a/cogs/meme.py +++ b/cogs/meme.py @@ -81,9 +81,10 @@ class Meme: @commands.check(check_if_staff_or_ot) @commands.command(hidden=True, name="bam") - async def bam_member(self, ctx, user: discord.Member): + async def bam_member(self, ctx, target: discord.Member): """Bams a user owo""" - await ctx.send(f"{self.bot.escape_message(user)} is ̶n͢ow b̕&̡.̷ 👍̡") + safe_name = await commands.clean_content().convert(ctx, str(target)) + await ctx.send(f"{safe_name} is ̶n͢ow b̕&̡.̷ 👍̡") @commands.command(hidden=True) async def memebercount(self, ctx): diff --git a/cogs/mod.py b/cogs/mod.py index 9d1ca51..9cfc400 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -27,7 +27,7 @@ class Mod: userlog(target.id, ctx.author, reason, "mutes", target.name) - safe_name = self.bot.escape_message(str(target)) + safe_name = await commands.clean_content().convert(ctx, str(target)) dm_message = f"You were muted!" if reason: @@ -64,7 +64,7 @@ class Mod: @commands.command() async def unmute(self, ctx, target: discord.Member): """Unmutes a user, staff only.""" - safe_name = self.bot.escape_message(str(target)) + safe_name = await commands.clean_content().convert(ctx, str(target)) mute_role = ctx.guild.get_role(config.mute_role) await target.remove_roles(mute_role, reason=str(ctx.author)) @@ -93,7 +93,7 @@ class Mod: userlog(target.id, ctx.author, reason, "kicks", target.name) - safe_name = self.bot.escape_message(str(target)) + safe_name = await commands.clean_content().convert(ctx, str(target)) dm_message = f"You were kicked from {ctx.guild.name}." if reason: @@ -138,7 +138,7 @@ class Mod: userlog(target.id, ctx.author, reason, "bans", target.name) - safe_name = self.bot.escape_message(str(target)) + safe_name = await commands.clean_content().convert(ctx, str(target)) dm_message = f"You were banned from {ctx.guild.name}." if reason: @@ -185,7 +185,7 @@ class Mod: userlog(target, ctx.author, reason, "bans", target_user.name) - safe_name = self.bot.escape_message(str(target_user)) + safe_name = await commands.clean_content().convert(ctx, str(target)) await ctx.guild.ban(target_user, reason=f"{ctx.author}, reason: {reason}", @@ -219,7 +219,7 @@ class Mod: userlog(target.id, ctx.author, reason, "bans", target.name) - safe_name = self.bot.escape_message(str(target)) + safe_name = await commands.clean_content().convert(ctx, str(target)) await target.ban(reason=f"{ctx.author}, reason: {reason}", delete_message_days=0) @@ -342,8 +342,10 @@ class Mod: delete_message_days=0) await ctx.send(f"{target.mention} warned. " f"User has {warn_count} warning(s).") + + safe_name = await commands.clean_content().convert(ctx, str(target)) msg = f"⚠️ **Warned**: {ctx.author.mention} warned {target.mention}"\ - f" (warn #{warn_count}) | {self.bot.escape_message(target)}\n" + f" (warn #{warn_count}) | {safe_name}\n" if reason: msg += f"✏️ __Reason__: \"{reason}\"" diff --git a/cogs/mod_timed.py b/cogs/mod_timed.py index 968d35a..29e694e 100644 --- a/cogs/mod_timed.py +++ b/cogs/mod_timed.py @@ -39,7 +39,7 @@ class ModTimed: f"{duration_text})", "bans", target.name) - safe_name = self.bot.escape_message(str(target)) + safe_name = await commands.clean_content().convert(ctx, str(target)) dm_message = f"You were banned from {ctx.guild.name}." if reason: @@ -95,7 +95,7 @@ class ModTimed: f"{duration_text})", "mutes", target.name) - safe_name = self.bot.escape_message(str(target)) + safe_name = await commands.clean_content().convert(ctx, str(target)) dm_message = f"You were muted!" if reason: diff --git a/cogs/mod_userlog.py b/cogs/mod_userlog.py index cf87452..61b193c 100644 --- a/cogs/mod_userlog.py +++ b/cogs/mod_userlog.py @@ -134,10 +134,11 @@ class ModUserlog: """Clears all events of given type for a user, staff only.""" log_channel = self.bot.get_channel(config.log_channel) msg = self.clear_event_from_id(str(target.id), event) + safe_name = await commands.clean_content().convert(ctx, str(target)) await ctx.send(msg) msg = f"🗑 **Cleared {event}**: {ctx.author.mention} cleared"\ f" all {event} events of {target.mention} | "\ - f"{self.bot.escape_message(target)}" + f"{safe_name}" await log_channel.send(msg) @commands.guild_only() @@ -164,10 +165,10 @@ class ModUserlog: # This is hell. if isinstance(del_event, discord.Embed): await ctx.send(f"{target.mention} has a {event_name} removed!") + safe_name = await commands.clean_content().convert(ctx, str(target)) msg = f"🗑 **Deleted {event_name}**: "\ f"{ctx.author.mention} removed "\ - f"{event_name} {idx} from {target.mention} | "\ - f"{self.bot.escape_message(target)}" + f"{event_name} {idx} from {target.mention} | {safe_name}" await log_channel.send(msg, embed=del_event) else: await ctx.send(del_event) diff --git a/cogs/remind.py b/cogs/remind.py index a1ae7e3..1587671 100644 --- a/cogs/remind.py +++ b/cogs/remind.py @@ -50,7 +50,7 @@ class Remind: include_to=True, humanized=True) - safe_text = self.bot.escape_message(str(text)) + safe_text = await commands.clean_content().convert(ctx, str(text)) added_on = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S (UTC)") add_job("remind", diff --git a/config.py.template b/config_template.py similarity index 96% rename from config.py.template rename to config_template.py index f0e87e8..80fad0a 100644 --- a/config.py.template +++ b/config_template.py @@ -3,7 +3,7 @@ import datetime # Basic bot config prefixes = [".", "!"] token = "token-goes-here" -bot_description = "An attempt to rewrite the bot used in ReSwitched" +bot_description = "Robocop-NG, the moderation bot of ReSwitched." source_url = "https://github.com/aveao/robocop-ng" rules_url = "https://reswitched.team/discord/" diff --git a/helpers/userlogs.py b/helpers/userlogs.py index 50bce0a..a7cc88c 100644 --- a/helpers/userlogs.py +++ b/helpers/userlogs.py @@ -19,8 +19,7 @@ def set_userlog(contents): def userlog(uid, issuer, reason, event_type, uname: str = ""): - with open("data/userlog.json", "r") as f: - userlogs = json.load(f) + userlogs = get_userlog() uid = str(uid) if uid not in userlogs: userlogs[uid] = {"warns": [], @@ -40,6 +39,5 @@ def userlog(uid, issuer, reason, event_type, uname: str = ""): if event_type not in userlogs[uid]: userlogs[uid][event_type] = [] userlogs[uid][event_type].append(log_data) - with open("data/userlog.json", "w") as f: - json.dump(userlogs, f) + set_userlog(json.dumps(userlogs)) return len(userlogs[uid][event_type])