From 6f6d6be9df976730c1ffb084bb76a7b4068a1d40 Mon Sep 17 00:00:00 2001 From: Myned Date: Wed, 11 Oct 2017 11:08:18 -0400 Subject: [PATCH 1/4] Checked for channel before looping --- src/main/cogs/management.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index 8fb4d7a..6860623 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -168,9 +168,14 @@ class Administration: @checks.del_ctx() async def auto_delete(self, ctx): channel = ctx.message.channel - u.background.setdefault('management', {}).setdefault('auto_delete', []).append(channel.id) - u.update(u.background, 'background.json') - self.bot.loop.create_task(self.on_message(channel)) - self.bot.loop.create_task(self.delete()) - print('Looping {}'.format(channel.id)) - await ctx.send('✅ **Auto-deleting all messages in this channel.**', delete_after=5) + + try: + if channel.id not in u.background['management']['auto_delete']: + u.background.setdefault('management', {}).setdefault('auto_delete', []).append(channel.id) + u.update(u.background, 'background.json') + self.bot.loop.create_task(self.on_message(channel)) + self.bot.loop.create_task(self.delete()) + print('Looping {}'.format(channel.id)) + await ctx.send('✅ **Auto-deleting all messages in this channel.**', delete_after=5) + else: raise exc.Exists + except exc.Exists: await ctx.send('❌ **Already deleting in this channel.**') From de967d68cb4990be557e400d661d3352ae8f56da Mon Sep 17 00:00:00 2001 From: Myned Date: Wed, 11 Oct 2017 11:08:32 -0400 Subject: [PATCH 2/4] Changed default perms --- src/main/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/run.py b/src/main/run.py index 0e68add..abf32ad 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -6,7 +6,7 @@ try: print('\"config.json\" loaded.') except FileNotFoundError: with open('config.json', 'w') as outfile: - json.dump({'client_id': 0, 'listed_ids': [0], 'owner_id': 0, 'permissions': 388160, 'prefix': ',', 'shutdown_channel': 0, 'startup_channel': 0, 'token': 'str'}, outfile, indent=4, sort_keys=True) + json.dump({'client_id': 0, 'listed_ids': [0], 'owner_id': 0, 'permissions': 126016, 'prefix': ',', 'shutdown_channel': 0, 'startup_channel': 0, 'token': 'str'}, outfile, indent=4, sort_keys=True) raise FileNotFoundError('Config file not found: \"config.json\" created with abstract values. Restart \"run.py\" with correct values.') import asyncio From a9b7689760ea7a83c42a304974e90c6277bbbeb3 Mon Sep 17 00:00:00 2001 From: Myned Date: Wed, 11 Oct 2017 11:08:46 -0400 Subject: [PATCH 3/4] Added Exists exception class --- src/main/misc/exceptions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/misc/exceptions.py b/src/main/misc/exceptions.py index 4c3e403..8db2366 100644 --- a/src/main/misc/exceptions.py +++ b/src/main/misc/exceptions.py @@ -3,6 +3,7 @@ base = '⚠️ **An internal error has occurred.** Please notify my master! 🐺 class Left(Exception): pass class Right(Exception): pass class Save(Exception): pass +class Exists(Exception): pass class PostError(Exception): pass class ImageError(Exception): pass class MatchError(Exception): pass From 5264a93050f785d493ad543ad57e50c91a2b6338 Mon Sep 17 00:00:00 2001 From: Myned Date: Wed, 11 Oct 2017 11:09:15 -0400 Subject: [PATCH 4/4] Rate limited post saves over 5 --- src/main/cogs/booru.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/cogs/booru.py b/src/main/cogs/booru.py index 821eda2..3b04df0 100644 --- a/src/main/cogs/booru.py +++ b/src/main/cogs/booru.py @@ -164,7 +164,10 @@ class MsG: tb.print_exc() finally: if starred: - for url in starred: await user.send(url) + for url in starred: + await user.send(url) + if len(starred) > 5: + await asyncio.sleep(2.1) @e621_paginator.error async def e621_paginator_error(self, ctx, error):