From f94303da601f63391898312f4170c3a571840fc6 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 15 Oct 2017 01:34:15 -0400 Subject: [PATCH 1/5] Changed http icon url to local --- src/main/cogs/booru.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/cogs/booru.py b/src/main/cogs/booru.py index 3094b45..f1a5f5d 100644 --- a/src/main/cogs/booru.py +++ b/src/main/cogs/booru.py @@ -175,7 +175,7 @@ class MsG: embed.set_author(name=pool['name'], url='https://e621.net/pool/show?id={}'.format(pool['id']), icon_url=user.avatar_url) embed.set_footer(text='{} / {}'.format(c, len(posts)), - icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + icon_url='icon_e6.png') paginator = await ctx.send(embed=embed) @@ -196,7 +196,7 @@ class MsG: embed.title = values[c - 1]['author'] embed.url = 'https://e621.net/post/show/{}'.format(keys[c - 1]) embed.set_footer(text='{} / {}'.format(c, len(posts)), - icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + icon_url='icon_e6.png') embed.set_image(url=values[c - 1]['url']) await paginator.edit(content=None, embed=embed) @@ -212,7 +212,7 @@ class MsG: embed.title = values[c - 1]['author'] embed.url = 'https://e621.net/post/show/{}'.format(keys[c - 1]) embed.set_footer(text='{} / {}'.format(c, len(posts)), - icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + icon_url='icon_e6.png') embed.set_image(url=values[c - 1]['url']) await paginator.edit(content=None, embed=embed) @@ -229,7 +229,7 @@ class MsG: embed.title = values[c - 1]['author'] embed.url = 'https://e621.net/post/show/{}'.format(keys[c - 1]) embed.set_footer(text='{} / {}'.format(c, len(posts)), - icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + icon_url='icon_e6.png') embed.set_image(url=values[c - 1]['url']) await paginator.edit(content=None, embed=embed) @@ -360,7 +360,7 @@ class MsG: embed.set_author(name=formatter.tostring(args, random=True), url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=user.avatar_url) embed.set_footer(text='{} / {}'.format(c, len(posts)), - icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + icon_url='icon_e6.png') paginator = await ctx.send(embed=embed) @@ -381,7 +381,7 @@ class MsG: embed.title = values[c - 1]['author'] embed.url = 'https://e621.net/post/show/{}'.format(keys[c - 1]) embed.set_footer(text='{} / {}'.format(c, len(posts)), - icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + icon_url='icon_e6.png') embed.set_image(url=values[c - 1]['url']) await paginator.edit(content=None, embed=embed) else: @@ -396,7 +396,7 @@ class MsG: embed.title = values[c - 1]['author'] embed.url = 'https://e621.net/post/show/{}'.format(keys[c - 1]) embed.set_footer(text='{} / {}'.format(c, len(posts)), - icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + icon_url='icon_e6.png') embed.set_image(url=values[c - 1]['url']) await paginator.edit(content=None, embed=embed) @@ -423,7 +423,7 @@ class MsG: embed.title = values[c - 1]['author'] embed.url = 'https://e621.net/post/show/{}'.format(keys[c - 1]) embed.set_footer(text='{} / {}'.format(c, len(posts)), - icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + icon_url='icon_e6.png') embed.set_image(url=values[c - 1]['url']) await paginator.edit(content=None, embed=embed) @@ -486,7 +486,7 @@ class MsG: embed.set_author(name=formatter.tostring(args, random=True), url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=user.avatar_url) embed.set_footer( - text=str(ident), icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + text=str(ident), icon_url='icon_e6.png') await ctx.send(embed=embed) except exc.TagBlacklisted as e: @@ -541,7 +541,7 @@ class MsG: embed.set_author(name=formatter.tostring(args, random=True), url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=user.avatar_url) embed.set_footer( - text=str(ident), icon_url='http://ndl.mgccw.com/mu3/app/20141013/18/1413204353554/icon/icon_xl.png') + text=str(ident), icon_url='icon_e6.png') await ctx.send(embed=embed) except exc.TagBlacklisted as e: From 85f7fc94304251346620e2de4164415f00dbfe4b Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 15 Oct 2017 01:34:34 -0400 Subject: [PATCH 2/5] Formatting change --- 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 2b51ca9..8ee88a8 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -43,7 +43,7 @@ async def on_ready(): @bot.event async def on_error(error, *args, **kwargs): if isinstance(bot.get_channel(u.config['shutdown_channel']), d.TextChannel): - await bot.get_channel(u.config['shutdown_channel']).send('**__ERROR__** ⚠️ {}\n**Exiting. . .**'.format(error)) + await bot.get_channel(u.config['shutdown_channel']).send('**ERROR** ⚠️ {}'.format(error)) u.close() await bot.logout() await bot.close() From 0b6b96450419233a5b84b4dbffb0be82003815c3 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 15 Oct 2017 01:34:52 -0400 Subject: [PATCH 3/5] WIP testing for help command --- src/main/cogs/info.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/cogs/info.py b/src/main/cogs/info.py index 9f3249b..1bdb7de 100644 --- a/src/main/cogs/info.py +++ b/src/main/cogs/info.py @@ -1,10 +1,11 @@ import asyncio import traceback as tb -import discord +import discord as d from discord.ext import commands from misc import exceptions as exc +from utils import utils as u class Info: @@ -12,8 +13,17 @@ class Info: def __init__(self, bot): self.bot = bot + # @commands.command(name='helptest', aliases=['h'], hidden=True) + # async def list_commands(self, ctx): + # embed = d.Embed(title='All possible commands:', color=ctx.me.color) + # embed.set_author(name=ctx.me.display_name, icon_url=ctx.me.avatar_url) + # embed.add_field( + # name='Booru', value='\n{}bl umbrella command for managing blacklists'.format(u.config['prefix'])) + # + # await ctx.send(embed=embed) + @commands.command(hidden=True) - async def hi(ctx): + async def hi(self, ctx): user = ctx.author hello = 'Hewwo, {}.'.format(user.mention) From f85e969dc65e86643f32b6a1676a16408b5fb241 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 15 Oct 2017 01:35:20 -0400 Subject: [PATCH 4/5] Caught failures to delete command invocations --- src/main/misc/checks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/misc/checks.py b/src/main/misc/checks.py index bcf7ae6..0c9891c 100644 --- a/src/main/misc/checks.py +++ b/src/main/misc/checks.py @@ -3,8 +3,9 @@ import json import traceback import discord +from discord import errors as err from discord.ext import commands -from discord.ext.commands import errors +from discord.ext.commands import errors as errext from utils import utils as u @@ -59,6 +60,11 @@ def is_nsfw(): def del_ctx(): async def predicate(ctx): if ctx.me.permissions_in(ctx.channel).manage_messages is True and isinstance(ctx.message.channel, discord.TextChannel) and ctx.guild.id in u.settings['del_ctx']: - await ctx.message.delete() + try: + await ctx.message.delete() + + except err.NotFound: + pass + return True return commands.check(predicate) From f706b4a18df4e366447594ccb0f57f3bd8bd4ec2 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 15 Oct 2017 01:49:10 -0400 Subject: [PATCH 5/5] Added ability to queue messages for deletion if they exist before cache --- src/main/cogs/management.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py index bcb858d..a8ea12e 100644 --- a/src/main/cogs/management.py +++ b/src/main/cogs/management.py @@ -19,7 +19,7 @@ class Administration: for channel in u.tasks.get('management', {}).get('auto_delete', []): temp = self.bot.get_channel(channel) - self.bot.loop.create_task(self.on_message(temp)) + self.bot.loop.create_task(self.queue_on_message(temp)) self.bot.loop.create_task(self.delete()) print('Looping #{}'.format(temp.name)) @@ -145,7 +145,7 @@ class Administration: except err.NotFound: pass - async def on_message(self, channel): + async def queue_on_message(self, channel): def check(msg): if msg.content.lower() == 'stop' and msg.channel is channel and msg.author.guild_permissions.administrator: raise exc.Abort @@ -155,6 +155,10 @@ class Administration: return False try: + async for message in channel.history(): + if not msg.pinned: + await self.queue.put(message) + while not self.bot.is_closed(): message = await self.bot.wait_for('message', check=check) await self.queue.put(message) @@ -178,7 +182,7 @@ class Administration: if channel.id not in u.tasks.setdefault('management', {}).setdefault('auto_delete', []): u.tasks['management']['auto_delete'].append(channel.id) u.dump(u.tasks, 'cogs/tasks.pkl') - self.bot.loop.create_task(self.on_message(channel)) + self.bot.loop.create_task(self.queue_on_message(channel)) self.bot.loop.create_task(self.delete()) print('Looping #{}'.format(channel.name)) await ctx.send('✅ **Auto-deleting all messages in this channel.**', delete_after=5)