diff options
Diffstat (limited to 'cogs')
-rwxr-xr-x | cogs/admin.py | 24 | ||||
-rwxr-xr-x | cogs/src.py | 8 |
2 files changed, 24 insertions, 8 deletions
diff --git a/cogs/admin.py b/cogs/admin.py index e1ed9bf..9b35be0 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -241,19 +241,33 @@ class Admin(commands.Cog): @commands.check(is_mod) async def blacklistvideo(self, ctx, uri): """Set runs from a specific url to be auto rejected""" - with open('video_blacklist.json', 'w') as f: - self.bot.video_blacklist.append(uri) + with open('runs_blacklist.json', 'w') as f: + self.bot.video_blacklist["videos"].append(uri) json.dump(self.bot.video_blacklist, f, indent=4) await ctx.send(f'Blacklisted runs from `{uri}`') @commands.command() @commands.check(is_mod) - async def video_blacklist(self, ctx): - """Sends a list of blacklisted uris""" + async def blacklistplayer(self, ctx, player): + """Set runs from a specific player to be auto rejected""" + with open('runs_blacklist.json', 'w') as f: + self.bot.video_blacklist["players"].append(uri) + json.dump(self.bot.video_blacklist, f, indent=4) + await ctx.send(f'Blacklisted runs from `{player}`') + + @commands.command() + @commands.check(is_mod) + async def runs_blacklist(self, ctx): + """Sends a list of blacklisted videos and players""" message = '```The following URIs are blacklisted:\n' - for uri in self.bot.video_blacklist: + for uri in self.bot.runs_blacklist["videos"]: message += f'{uri}, ' await ctx.send(f'{message[:-2]}```') + message = '```The following players are blacklisted:\n' + for player in self.bot.runs_blacklist["players"]: + message += f'{player}, ' + await ctx.send(f'{message[:-2]}```') + def setup(bot): bot.add_cog(Admin(bot)) diff --git a/cogs/src.py b/cogs/src.py index 8afe1b5..58e72af 100755 --- a/cogs/src.py +++ b/cogs/src.py @@ -22,7 +22,7 @@ async def rejectRun(self, apiKey, ctx, run, reason): }, data=json.dumps(reject)) if r.status_code == 200 or r.status_code == 204: - await ctx.send("Run rejected succesfully") + await ctx.send(f'Run rejected succesfully for {reason}') else: await ctx.send("Something went wrong") await ctx.message.author.send( @@ -102,12 +102,14 @@ async def pendingRuns(self, ctx): if key == 'category' and not level: categoryName = value["data"]["name"] if key == 'videos': - if value['links'][0]['uri'] in self.bot.video_blacklist: + if value['links'][0]['uri'] in self.bot.runs_blacklist["videos"]: await rejectRun( self, self.bot.config['api_key'], ctx, run_id, 'Detected as spam by our automatic filter') if key == 'players': - if value["data"][0]['rel'] == 'guest': + if value["data"[0]["names"]["international"] in self.bot.runs_blacklist["players"]: + await rejectRun(self, self.bot.config['api_key'], ctx, run_id, 'Banned player. https://www.speedrun.com/mcbe/thread/5cuo8/1#d2m6x') + elif value["data"][0]['rel'] == 'guest': player = value["data"][0]['name'] else: player = value["data"][0]["names"]["international"] |