diff options
Diffstat (limited to 'cogs')
-rwxr-xr-x | cogs/admin.py | 9 | ||||
-rwxr-xr-x | cogs/src.py | 3 | ||||
-rwxr-xr-x | cogs/utils.py | 40 |
3 files changed, 43 insertions, 9 deletions
diff --git a/cogs/admin.py b/cogs/admin.py index 014d4cb..ed7b7cc 100755 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -292,15 +292,18 @@ class Admin(commands.Cog): async def delvar(self, ctx, key): """Deletes a config variable, be careful""" with open('config.json', 'w') as f: - await ctx.send(f"Removed {self.bot.config[str(ctx.message.guild.id)].pop(key)}") + await ctx.send( + f"Removed {self.bot.config[str(ctx.message.guild.id)].pop(key)}" + ) json.dump(self.bot.config, f, indent=4) @commands.command() @commands.check(is_mod) async def blacklistvideo(self, ctx, uri): """Set runs from a specific url to be auto rejected""" + video_id = uri.split('/')[-1].split('=')[-1] with open('runs_blacklist.json', 'w') as f: - self.bot.runs_blacklist["videos"].append(uri) + self.bot.runs_blacklist["videos"].append(video_id) json.dump(self.bot.runs_blacklist, f, indent=4) await ctx.send(f'Blacklisted runs from `{uri}`') @@ -317,7 +320,7 @@ class Admin(commands.Cog): @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' + message = '```The following videos are blacklisted:\n' for uri in self.bot.runs_blacklist["videos"]: message += f'{uri}, ' await ctx.send(f'{message[:-2]}```') diff --git a/cogs/src.py b/cogs/src.py index 74390e6..e3192e7 100755 --- a/cogs/src.py +++ b/cogs/src.py @@ -152,7 +152,8 @@ async def pendingRuns(self, ctx): for run in pending_runs: # Reject run if video is blacklisted - if run.video in self.bot.runs_blacklist["videos"]: + if run.video.split('/')[-1].split( + '=')[-1] in self.bot.runs_blacklist["videos"]: runs_to_reject.append( [run, 'Detected as spam by our automatic filter.']) diff --git a/cogs/utils.py b/cogs/utils.py index 2a77653..477f3be 100755 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -222,9 +222,6 @@ class Utils(commands.Cog): async def on_message(self, message): if not message.guild: return - if message.channel.id != int(self.bot.config[str( - message.guild.id)]["fair_channel"]): - return if message.author.bot: return badWords = ["fair", "ⓕⓐⓘⓡ"] @@ -294,7 +291,7 @@ class Utils(commands.Cog): datetime.date(2020, 9, 29) ], [ - 'Samantha', # This one is Zyemlus + 'Samantha', # This one is Zyemlus self.bot.get_user(536071288859656193), datetime.date(2020, 8, 23) ], @@ -307,6 +304,11 @@ class Utils(commands.Cog): 'Oceanlight', self.bot.get_user(615658069132836865), datetime.date(2020, 4, 9) + ], + [ + 'Shadowfi', + self.bot.get_user(586664256217415681), + datetime.date(2020, 11, 14) ] ] @@ -315,7 +317,7 @@ class Utils(commands.Cog): try: for i in range(self.tries): await coolKid[1].send( - f'Happy Birthday {coolKid[0]}! You\'re a boomer now! :mango:' + f'Happy Birthday {coolKid[0]}! You\'re a boomer now! <:mangopog:730683234039365722>' ) self.tries = 1 except: @@ -382,5 +384,33 @@ class Utils(commands.Cog): output = ", ".join([*commands]) await ctx.send(f"```List of custom commands:\n{output}```") + @commands.command() + async def retime(self, ctx, start_sec, end_sec, frames=0, framerate=30): + """Retimes a run using the start/end timestamps, leftover frames, and framerate""" + if start_sec.count(':') == 2: + start_sec = sum( + x * int(t) + for x, t in zip([3600, 60, 1], start_sec.split(":"))) + elif start_sec.count(':') == 1: + start_sec = sum(x * int(t) + for x, t in zip([60, 1], start_sec.split(":"))) + else: + start_sec = int(start_sec) + + if end_sec.count(':') == 2: + end_sec = sum(x * int(t) + for x, t in zip([3600, 60, 1], end_sec.split(":"))) + elif end_sec.count(':') == 1: + end_sec = sum(x * int(t) + for x, t in zip([60, 1], end_sec.split(":"))) + else: + end_sec = int(end_sec) + + await ctx.send( + str( + timedelta(seconds=end_sec - start_sec + + round((int(frames) / int(framerate)), 3))).replace('000', '')) + + def setup(bot): bot.add_cog(Utils(bot)) |