Push some stuff I forgot to push

This commit is contained in:
Ave Ozkal 2019-01-07 11:49:19 +03:00
parent 65989b4c19
commit 48a22c5fa8
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B
11 changed files with 34 additions and 26 deletions

View file

@ -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: 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 - [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 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 moderation feature: watch-unwatch (using log module from akbbot)
- [ ] New feature: Modmail - [ ] New feature: Modmail

View file

@ -97,7 +97,8 @@ async def on_ready():
data_files = [discord.File(fpath) for fpath in wanted_jsons] data_files = [discord.File(fpath) for fpath in wanted_jsons]
await bot.botlog_channel.send(msg, files=data_files) 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) await bot.change_presence(activity=activity)

View file

@ -32,9 +32,11 @@ class Links:
@commands.command(hidden=True, aliases=["guides"]) @commands.command(hidden=True, aliases=["guides"])
async def guide(self, ctx): async def guide(self, ctx):
"""Link to the guide(s)""" """Link to the guide(s)"""
await ctx.send("*AtlasNX's Guide:* https://guide.teamatlasnx.com\n" await ctx.send("Nintendo Homebrew's Guide: "
"*Noirscape's Guide:* http://switchguide.xyz/\n" "<https://nh-server.github.io/switch-guide/>\n"
"*Pegaswitch Guide:* https://switch.hacks.guide/") "Noirscape's Guide: <http://switchguide.xyz/>\n"
"Pegaswitch Guide: <https://switch.hacks.guide/> "
"(outdated for anything but Pegaswitch)")
def setup(bot): def setup(bot):

View file

@ -50,8 +50,9 @@ class Lockdown:
"disciplinary actions." "disciplinary actions."
await ctx.send(public_msg) 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} "\ 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) await log_channel.send(msg)
@commands.guild_only() @commands.guild_only()
@ -77,9 +78,10 @@ class Lockdown:
send_messages=True, send_messages=True,
reason=str(ctx.author)) reason=str(ctx.author))
safe_name = await commands.clean_content().convert(ctx, str(ctx.author))
await ctx.send("🔓 Channel unlocked.") await ctx.send("🔓 Channel unlocked.")
msg = f"🔓 **Unlock**: {ctx.channel.mention} by {ctx.author.mention} "\ 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) await log_channel.send(msg)

View file

@ -81,9 +81,10 @@ class Meme:
@commands.check(check_if_staff_or_ot) @commands.check(check_if_staff_or_ot)
@commands.command(hidden=True, name="bam") @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""" """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) @commands.command(hidden=True)
async def memebercount(self, ctx): async def memebercount(self, ctx):

View file

@ -27,7 +27,7 @@ class Mod:
userlog(target.id, ctx.author, reason, "mutes", target.name) 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!" dm_message = f"You were muted!"
if reason: if reason:
@ -64,7 +64,7 @@ class Mod:
@commands.command() @commands.command()
async def unmute(self, ctx, target: discord.Member): async def unmute(self, ctx, target: discord.Member):
"""Unmutes a user, staff only.""" """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) mute_role = ctx.guild.get_role(config.mute_role)
await target.remove_roles(mute_role, reason=str(ctx.author)) 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) 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}." dm_message = f"You were kicked from {ctx.guild.name}."
if reason: if reason:
@ -138,7 +138,7 @@ class Mod:
userlog(target.id, ctx.author, reason, "bans", target.name) 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}." dm_message = f"You were banned from {ctx.guild.name}."
if reason: if reason:
@ -185,7 +185,7 @@ class Mod:
userlog(target, ctx.author, reason, "bans", target_user.name) 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, await ctx.guild.ban(target_user,
reason=f"{ctx.author}, reason: {reason}", reason=f"{ctx.author}, reason: {reason}",
@ -219,7 +219,7 @@ class Mod:
userlog(target.id, ctx.author, reason, "bans", target.name) 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}", await target.ban(reason=f"{ctx.author}, reason: {reason}",
delete_message_days=0) delete_message_days=0)
@ -342,8 +342,10 @@ class Mod:
delete_message_days=0) delete_message_days=0)
await ctx.send(f"{target.mention} warned. " await ctx.send(f"{target.mention} warned. "
f"User has {warn_count} warning(s).") 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}"\ 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: if reason:
msg += f"✏️ __Reason__: \"{reason}\"" msg += f"✏️ __Reason__: \"{reason}\""

View file

@ -39,7 +39,7 @@ class ModTimed:
f"{duration_text})", f"{duration_text})",
"bans", target.name) "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}." dm_message = f"You were banned from {ctx.guild.name}."
if reason: if reason:
@ -95,7 +95,7 @@ class ModTimed:
f"{duration_text})", f"{duration_text})",
"mutes", target.name) "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!" dm_message = f"You were muted!"
if reason: if reason:

View file

@ -134,10 +134,11 @@ class ModUserlog:
"""Clears all events of given type for a user, staff only.""" """Clears all events of given type for a user, staff only."""
log_channel = self.bot.get_channel(config.log_channel) log_channel = self.bot.get_channel(config.log_channel)
msg = self.clear_event_from_id(str(target.id), event) msg = self.clear_event_from_id(str(target.id), event)
safe_name = await commands.clean_content().convert(ctx, str(target))
await ctx.send(msg) await ctx.send(msg)
msg = f"🗑 **Cleared {event}**: {ctx.author.mention} cleared"\ msg = f"🗑 **Cleared {event}**: {ctx.author.mention} cleared"\
f" all {event} events of {target.mention} | "\ f" all {event} events of {target.mention} | "\
f"{self.bot.escape_message(target)}" f"{safe_name}"
await log_channel.send(msg) await log_channel.send(msg)
@commands.guild_only() @commands.guild_only()
@ -164,10 +165,10 @@ class ModUserlog:
# This is hell. # This is hell.
if isinstance(del_event, discord.Embed): if isinstance(del_event, discord.Embed):
await ctx.send(f"{target.mention} has a {event_name} removed!") 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}**: "\ msg = f"🗑 **Deleted {event_name}**: "\
f"{ctx.author.mention} removed "\ f"{ctx.author.mention} removed "\
f"{event_name} {idx} from {target.mention} | "\ f"{event_name} {idx} from {target.mention} | {safe_name}"
f"{self.bot.escape_message(target)}"
await log_channel.send(msg, embed=del_event) await log_channel.send(msg, embed=del_event)
else: else:
await ctx.send(del_event) await ctx.send(del_event)

View file

@ -50,7 +50,7 @@ class Remind:
include_to=True, include_to=True,
humanized=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)") added_on = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S (UTC)")
add_job("remind", add_job("remind",

View file

@ -3,7 +3,7 @@ import datetime
# Basic bot config # Basic bot config
prefixes = [".", "!"] prefixes = [".", "!"]
token = "token-goes-here" 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" source_url = "https://github.com/aveao/robocop-ng"
rules_url = "https://reswitched.team/discord/" rules_url = "https://reswitched.team/discord/"

View file

@ -19,8 +19,7 @@ def set_userlog(contents):
def userlog(uid, issuer, reason, event_type, uname: str = ""): def userlog(uid, issuer, reason, event_type, uname: str = ""):
with open("data/userlog.json", "r") as f: userlogs = get_userlog()
userlogs = json.load(f)
uid = str(uid) uid = str(uid)
if uid not in userlogs: if uid not in userlogs:
userlogs[uid] = {"warns": [], userlogs[uid] = {"warns": [],
@ -40,6 +39,5 @@ def userlog(uid, issuer, reason, event_type, uname: str = ""):
if event_type not in userlogs[uid]: if event_type not in userlogs[uid]:
userlogs[uid][event_type] = [] userlogs[uid][event_type] = []
userlogs[uid][event_type].append(log_data) userlogs[uid][event_type].append(log_data)
with open("data/userlog.json", "w") as f: set_userlog(json.dumps(userlogs))
json.dump(userlogs, f)
return len(userlogs[uid][event_type]) return len(userlogs[uid][event_type])