mirror of
https://github.com/myned/modufur.git
synced 2024-12-25 06:37:29 +00:00
Revert migration to destination resolving
Better implementation will be added in the future
This commit is contained in:
parent
4feca45f5e
commit
8f103d0f27
3 changed files with 95 additions and 123 deletions
|
@ -228,11 +228,11 @@ class MsG:
|
||||||
@tags.command(name='related', aliases=['relate', 'rel', 'r'], brief='(tags) Search for related tags', description='Return related tags for given tag(s)\n\nExample:\n\{p\}tag related wolf')
|
@tags.command(name='related', aliases=['relate', 'rel', 'r'], brief='(tags) Search for related tags', description='Return related tags for given tag(s)\n\nExample:\n\{p\}tag related wolf')
|
||||||
async def _tags_related(self, ctx, *args):
|
async def _tags_related(self, ctx, *args):
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
related = []
|
related = []
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
tag_request = await u.fetch('https://e621.net/tag/related.json', params={'tags': tag}, json=True)
|
tag_request = await u.fetch('https://e621.net/tag/related.json', params={'tags': tag}, json=True)
|
||||||
|
@ -240,7 +240,7 @@ class MsG:
|
||||||
related.append(rel[0])
|
related.append(rel[0])
|
||||||
|
|
||||||
if related:
|
if related:
|
||||||
await dest.send('`{}` **related tags:**\n```\n{}```'.format(tag, formatter.tostring(related)))
|
await ctx.send('`{}` **related tags:**\n```\n{}```'.format(tag, ' '.join(related)))
|
||||||
else:
|
else:
|
||||||
await ctx.send(f'**No related tags found for:** `{tag}`')
|
await ctx.send(f'**No related tags found for:** `{tag}`')
|
||||||
|
|
||||||
|
@ -254,11 +254,11 @@ class MsG:
|
||||||
@tags.command(name='aliases', aliases=['alias', 'als', 'a'], brief='(tags) Search for tag aliases', description='Return aliases for given tag(s)\n\nExample:\n\{p\}tag alias wolf')
|
@tags.command(name='aliases', aliases=['alias', 'als', 'a'], brief='(tags) Search for tag aliases', description='Return aliases for given tag(s)\n\nExample:\n\{p\}tag alias wolf')
|
||||||
async def _tags_aliases(self, ctx, *args):
|
async def _tags_aliases(self, ctx, *args):
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
aliases = []
|
aliases = []
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
alias_request = await u.fetch('https://e621.net/tag_alias/index.json', params={'aliased_to': tag, 'approved': 'true'}, json=True)
|
alias_request = await u.fetch('https://e621.net/tag_alias/index.json', params={'aliased_to': tag, 'approved': 'true'}, json=True)
|
||||||
|
@ -266,7 +266,7 @@ class MsG:
|
||||||
aliases.append(dic['name'])
|
aliases.append(dic['name'])
|
||||||
|
|
||||||
if aliases:
|
if aliases:
|
||||||
await dest.send('`{}` **aliases:**\n```\n{}```'.format(tag, formatter.tostring(aliases)))
|
await ctx.send('`{}` **aliases:**\n```\n{}```'.format(tag, ' '.join(aliases)))
|
||||||
else:
|
else:
|
||||||
await ctx.send(f'**No aliases found for:** `{tag}`')
|
await ctx.send(f'**No aliases found for:** `{tag}`')
|
||||||
|
|
||||||
|
@ -286,13 +286,13 @@ class MsG:
|
||||||
async def _get_info(self, ctx, *args):
|
async def _get_info(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, posts = kwargs['destination'], kwargs['remaining']
|
posts = kwargs['remaining']
|
||||||
|
|
||||||
if not posts:
|
if not posts:
|
||||||
raise exc.MissingArgument
|
raise exc.MissingArgument
|
||||||
|
|
||||||
for ident in posts:
|
for ident in posts:
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
ident = ident if not ident.isdigit() else re.search(
|
ident = ident if not ident.isdigit() else re.search(
|
||||||
'show/([0-9]+)', ident).group(1)
|
'show/([0-9]+)', ident).group(1)
|
||||||
|
@ -314,16 +314,16 @@ class MsG:
|
||||||
async def _get_image(self, ctx, *args):
|
async def _get_image(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, urls = kwargs['destination'], kwargs['remaining']
|
urls = kwargs['remaining']
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
if not urls:
|
if not urls:
|
||||||
raise exc.MissingArgument
|
raise exc.MissingArgument
|
||||||
|
|
||||||
for url in urls:
|
for url in urls:
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
await dest.send(await scraper.get_image(url))
|
await ctx.send(await scraper.get_image(url))
|
||||||
|
|
||||||
c += 1
|
c += 1
|
||||||
|
|
||||||
|
@ -349,10 +349,10 @@ class MsG:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, query = kwargs['destination'], kwargs['remaining']
|
query = kwargs['remaining']
|
||||||
ident = None
|
ident = None
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
pools = []
|
pools = []
|
||||||
pool_request = await u.fetch('https://e621.net/pool/index.json', params={'query': ' '.join(query)}, json=True)
|
pool_request = await u.fetch('https://e621.net/pool/index.json', params={'query': ' '.join(query)}, json=True)
|
||||||
|
@ -388,7 +388,7 @@ class MsG:
|
||||||
async def reverse(self, ctx, *args):
|
async def reverse(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, urls, remove = kwargs['destination'], kwargs['remaining'], kwargs['remove']
|
urls, remove = kwargs['remaining'], kwargs['remove']
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
if not urls and not ctx.message.attachments:
|
if not urls and not ctx.message.attachments:
|
||||||
|
@ -399,7 +399,7 @@ class MsG:
|
||||||
|
|
||||||
for url in urls:
|
for url in urls:
|
||||||
try:
|
try:
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
post = await scraper.get_post(url)
|
post = await scraper.get_post(url)
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ class MsG:
|
||||||
embed.set_footer(text=post['score'],
|
embed.set_footer(text=post['score'],
|
||||||
icon_url=self._get_score(post['score']))
|
icon_url=self._get_score(post['score']))
|
||||||
|
|
||||||
await dest.send('**Probable match**', embed=embed)
|
await ctx.send('**Probable match**', embed=embed)
|
||||||
|
|
||||||
c += 1
|
c += 1
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ class MsG:
|
||||||
async def reversify(self, ctx, *args):
|
async def reversify(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5)
|
kwargs = u.get_kwargs(ctx, args, limit=self.HISTORY_LIMIT / 5)
|
||||||
dest, remove, limit = kwargs['destination'], kwargs['remove'], kwargs['limit']
|
remove, limit = kwargs['remove'], kwargs['limit']
|
||||||
links = {}
|
links = {}
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ class MsG:
|
||||||
for message, urls in links.items():
|
for message, urls in links.items():
|
||||||
for url in urls:
|
for url in urls:
|
||||||
try:
|
try:
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
post = await scraper.get_post(url)
|
post = await scraper.get_post(url)
|
||||||
|
|
||||||
|
@ -488,11 +488,11 @@ class MsG:
|
||||||
await message.delete()
|
await message.delete()
|
||||||
|
|
||||||
except exc.MatchError as e:
|
except exc.MatchError as e:
|
||||||
await ctx.send('`{} / {}` **No probable match for:** `{}`'.format(n, len(links), e))
|
await dest.send('`{} / {}` **No probable match for:** `{}`'.format(n, len(links), e))
|
||||||
await message.add_reaction('\N{CROSS MARK}')
|
await message.add_reaction('\N{CROSS MARK}')
|
||||||
c -= 1
|
c -= 1
|
||||||
except exc.SizeError as e:
|
except exc.SizeError as e:
|
||||||
await ctx.send(f'`{e}` **too large.** Maximum is 8 MB')
|
await dest.send(f'`{e}` **too large.** Maximum is 8 MB')
|
||||||
await message.add_reaction('\N{CROSS MARK}')
|
await message.add_reaction('\N{CROSS MARK}')
|
||||||
c -= 1
|
c -= 1
|
||||||
|
|
||||||
|
@ -503,13 +503,13 @@ class MsG:
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
except exc.NotFound:
|
except exc.NotFound:
|
||||||
await ctx.send('**No matches found**')
|
await dest.send('**No matches found**')
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
except exc.BoundsError as e:
|
except exc.BoundsError as e:
|
||||||
await ctx.send('`{}` **invalid limit.** Query limited to 30'.format(e))
|
await dest.send('`{}` **invalid limit.** Query limited to 30'.format(e))
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
except Exception:
|
except Exception:
|
||||||
await ctx.send('**The image database is offline.** Please try again later')
|
await dest.send('**The image database is offline.** Please try again later')
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
async def _reversify(self):
|
async def _reversify(self):
|
||||||
|
@ -598,7 +598,7 @@ class MsG:
|
||||||
await ctx.send('**Already auto-reversifying in {}.** Type `stop r(eversifying)` to stop.'.format(ctx.channel.mention))
|
await ctx.send('**Already auto-reversifying in {}.** Type `stop r(eversifying)` to stop.'.format(ctx.channel.mention))
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
async def _get_pool(self, ctx, *, destination, booru='e621', query=[]):
|
async def _get_pool(self, ctx, *, booru='e621', query=[]):
|
||||||
def on_reaction(reaction, user):
|
def on_reaction(reaction, user):
|
||||||
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and user is ctx.author:
|
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and user is ctx.author:
|
||||||
raise exc.Abort(match)
|
raise exc.Abort(match)
|
||||||
|
@ -632,7 +632,7 @@ class MsG:
|
||||||
await selection.delete()
|
await selection.delete()
|
||||||
pool = {'name': tempool['name'], 'id': tempool['id']}
|
pool = {'name': tempool['name'], 'id': tempool['id']}
|
||||||
|
|
||||||
await destination.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
elif pool_request:
|
elif pool_request:
|
||||||
tempool = pool_request[0]
|
tempool = pool_request[0]
|
||||||
pool = {'name': pool_request[0]
|
pool = {'name': pool_request[0]
|
||||||
|
@ -743,25 +743,25 @@ class MsG:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, query = kwargs['destination'], kwargs['remaining']
|
query = kwargs['remaining']
|
||||||
hearted = {}
|
hearted = {}
|
||||||
c = 1
|
c = 1
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
pool, posts = await self._get_pool(ctx, destination=dest, booru='e621', query=query)
|
pool, posts = await self._get_pool(ctx, booru='e621', query=query)
|
||||||
keys = list(posts.keys())
|
keys = list(posts.keys())
|
||||||
values = list(posts.values())
|
values = list(posts.values())
|
||||||
|
|
||||||
embed = d.Embed(
|
embed = d.Embed(
|
||||||
title=values[c - 1]['artist'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=dest.me.color if isinstance(dest.channel, d.TextChannel) else u.color)
|
title=values[c - 1]['artist'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else u.color)
|
||||||
embed.set_image(url=values[c - 1]['file_url'])
|
embed.set_image(url=values[c - 1]['file_url'])
|
||||||
embed.set_author(name=pool['name'],
|
embed.set_author(name=pool['name'],
|
||||||
url='https://e621.net/pool/show?id={}'.format(pool['id']), icon_url=ctx.author.avatar_url)
|
url='https://e621.net/pool/show?id={}'.format(pool['id']), icon_url=ctx.author.avatar_url)
|
||||||
embed.set_footer(text='{} / {}'.format(c, len(posts)),
|
embed.set_footer(text='{} / {}'.format(c, len(posts)),
|
||||||
icon_url=self._get_score(values[c - 1]['score']))
|
icon_url=self._get_score(values[c - 1]['score']))
|
||||||
|
|
||||||
paginator = await dest.send(embed=embed)
|
paginator = await ctx.send(embed=embed)
|
||||||
|
|
||||||
for emoji in ('\N{HEAVY BLACK HEART}', '\N{LEFTWARDS BLACK ARROW}', '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}', '\N{BLACK RIGHTWARDS ARROW}'):
|
for emoji in ('\N{HEAVY BLACK HEART}', '\N{LEFTWARDS BLACK ARROW}', '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}', '\N{BLACK RIGHTWARDS ARROW}'):
|
||||||
await paginator.add_reaction(emoji)
|
await paginator.add_reaction(emoji)
|
||||||
|
@ -835,12 +835,12 @@ class MsG:
|
||||||
try:
|
try:
|
||||||
await paginator.edit(content='\N{WHITE HEAVY CHECK MARK}')
|
await paginator.edit(content='\N{WHITE HEAVY CHECK MARK}')
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('\N{WHITE HEAVY CHECK MARK}')
|
await ctx.send('\N{WHITE HEAVY CHECK MARK}')
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
try:
|
try:
|
||||||
await paginator.edit(content='\N{HOURGLASS}')
|
await paginator.edit(content='\N{HOURGLASS}')
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('\N{HOURGLASS}')
|
await ctx.send('\N{HOURGLASS}')
|
||||||
except exc.NotFound:
|
except exc.NotFound:
|
||||||
await ctx.send('**Pool not found**')
|
await ctx.send('**Pool not found**')
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
@ -880,7 +880,7 @@ class MsG:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
limit = self.LIMIT / 5
|
limit = self.LIMIT / 5
|
||||||
hearted = {}
|
hearted = {}
|
||||||
c = 1
|
c = 1
|
||||||
|
@ -901,7 +901,7 @@ class MsG:
|
||||||
embed.set_footer(text=values[c - 1]['score'],
|
embed.set_footer(text=values[c - 1]['score'],
|
||||||
icon_url=self._get_score(values[c - 1]['score']))
|
icon_url=self._get_score(values[c - 1]['score']))
|
||||||
|
|
||||||
paginator = await dest.send(embed=embed)
|
paginator = await ctx.send(embed=embed)
|
||||||
|
|
||||||
for emoji in ('\N{HEAVY BLACK HEART}', '\N{LEFTWARDS BLACK ARROW}', '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}', '\N{BLACK RIGHTWARDS ARROW}'):
|
for emoji in ('\N{HEAVY BLACK HEART}', '\N{LEFTWARDS BLACK ARROW}', '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}', '\N{BLACK RIGHTWARDS ARROW}'):
|
||||||
await paginator.add_reaction(emoji)
|
await paginator.add_reaction(emoji)
|
||||||
|
@ -960,7 +960,7 @@ class MsG:
|
||||||
except exc.Right:
|
except exc.Right:
|
||||||
try:
|
try:
|
||||||
if c % limit == 0:
|
if c % limit == 0:
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
temposts, order = await self._get_posts(ctx, booru='e621', tags=tags, limit=limit, previous=posts)
|
temposts, order = await self._get_posts(ctx, booru='e621', tags=tags, limit=limit, previous=posts)
|
||||||
posts.update(temposts)
|
posts.update(temposts)
|
||||||
|
|
||||||
|
@ -987,12 +987,12 @@ class MsG:
|
||||||
try:
|
try:
|
||||||
await paginator.edit(content='\N{WHITE HEAVY CHECK MARK}')
|
await paginator.edit(content='\N{WHITE HEAVY CHECK MARK}')
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('\N{HOURGLASS}')
|
await ctx.send('\N{HOURGLASS}')
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
try:
|
try:
|
||||||
await paginator.edit(content='\N{HOURGLASS}')
|
await paginator.edit(content='\N{HOURGLASS}')
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('\N{HOURGLASS}')
|
await ctx.send('\N{HOURGLASS}')
|
||||||
except exc.NotFound as e:
|
except exc.NotFound as e:
|
||||||
await ctx.send('`{}` **not found**'.format(e))
|
await ctx.send('`{}` **not found**'.format(e))
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
@ -1044,7 +1044,7 @@ class MsG:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
limit = self.LIMIT / 5
|
limit = self.LIMIT / 5
|
||||||
hearted = {}
|
hearted = {}
|
||||||
c = 1
|
c = 1
|
||||||
|
@ -1065,7 +1065,7 @@ class MsG:
|
||||||
embed.set_footer(text=values[c - 1]['score'],
|
embed.set_footer(text=values[c - 1]['score'],
|
||||||
icon_url=self._get_score(values[c - 1]['score']))
|
icon_url=self._get_score(values[c - 1]['score']))
|
||||||
|
|
||||||
paginator = await dest.send(embed=embed)
|
paginator = await ctx.send(embed=embed)
|
||||||
|
|
||||||
for emoji in ('\N{HEAVY BLACK HEART}', '\N{LEFTWARDS BLACK ARROW}', '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}', '\N{BLACK RIGHTWARDS ARROW}'):
|
for emoji in ('\N{HEAVY BLACK HEART}', '\N{LEFTWARDS BLACK ARROW}', '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}', '\N{BLACK RIGHTWARDS ARROW}'):
|
||||||
await paginator.add_reaction(emoji)
|
await paginator.add_reaction(emoji)
|
||||||
|
@ -1122,7 +1122,7 @@ class MsG:
|
||||||
except exc.Right:
|
except exc.Right:
|
||||||
try:
|
try:
|
||||||
if c % limit == 0:
|
if c % limit == 0:
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
temposts, order = await self._get_posts(ctx, booru='e926', tags=tags, limit=limit, previous=posts)
|
temposts, order = await self._get_posts(ctx, booru='e926', tags=tags, limit=limit, previous=posts)
|
||||||
posts.update(temposts)
|
posts.update(temposts)
|
||||||
|
|
||||||
|
@ -1149,12 +1149,12 @@ class MsG:
|
||||||
try:
|
try:
|
||||||
await paginator.edit(content='\N{WHITE HEAVY CHECK MARK}')
|
await paginator.edit(content='\N{WHITE HEAVY CHECK MARK}')
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('\N{WHITE HEAVY CHECK MARK}')
|
await ctx.send('\N{WHITE HEAVY CHECK MARK}')
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
try:
|
try:
|
||||||
await paginator.edit(content='\N{HOURGLASS}')
|
await paginator.edit(content='\N{HOURGLASS}')
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('\N{HOURGLASS}')
|
await ctx.send('\N{HOURGLASS}')
|
||||||
except exc.NotFound as e:
|
except exc.NotFound as e:
|
||||||
await ctx.send('`{}` **not found**'.format(e))
|
await ctx.send('`{}` **not found**'.format(e))
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
@ -1186,11 +1186,11 @@ class MsG:
|
||||||
async def e621(self, ctx, *args):
|
async def e621(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args, limit=3)
|
kwargs = u.get_kwargs(ctx, args, limit=3)
|
||||||
dest, args, limit = kwargs['destination'], kwargs['remaining'], kwargs['limit']
|
args, limit = kwargs['remaining'], kwargs['limit']
|
||||||
|
|
||||||
tags = self._get_favorites(ctx, args)
|
tags = self._get_favorites(ctx, args)
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
posts, order = await self._get_posts(ctx, booru='e621', tags=tags, limit=limit)
|
posts, order = await self._get_posts(ctx, booru='e621', tags=tags, limit=limit)
|
||||||
|
|
||||||
|
@ -1203,7 +1203,7 @@ class MsG:
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
text=post['score'], icon_url=self._get_score(post['score']))
|
text=post['score'], icon_url=self._get_score(post['score']))
|
||||||
|
|
||||||
message = await dest.send(embed=embed)
|
message = await ctx.send(embed=embed)
|
||||||
|
|
||||||
self.bot.loop.create_task(self.queue_for_hearts(message=message, send=embed))
|
self.bot.loop.create_task(self.queue_for_hearts(message=message, send=embed))
|
||||||
|
|
||||||
|
@ -1237,11 +1237,11 @@ class MsG:
|
||||||
async def e926(self, ctx, *args):
|
async def e926(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args, limit=3)
|
kwargs = u.get_kwargs(ctx, args, limit=3)
|
||||||
dest, args, limit = kwargs['destination'], kwargs['remaining'], kwargs['limit']
|
args, limit = kwargs['remaining'], kwargs['limit']
|
||||||
|
|
||||||
tags = self._get_favorites(ctx, args)
|
tags = self._get_favorites(ctx, args)
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
posts, order = await self._get_posts(ctx, booru='e926', tags=tags, limit=limit)
|
posts, order = await self._get_posts(ctx, booru='e926', tags=tags, limit=limit)
|
||||||
|
|
||||||
|
@ -1254,7 +1254,7 @@ class MsG:
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
text=post['score'], icon_url=self._get_score(post['score']))
|
text=post['score'], icon_url=self._get_score(post['score']))
|
||||||
|
|
||||||
message = await dest.send(embed=embed)
|
message = await ctx.send(embed=embed)
|
||||||
|
|
||||||
self.bot.loop.create_task(self.queue_for_hearts(message=message, send=embed))
|
self.bot.loop.create_task(self.queue_for_hearts(message=message, send=embed))
|
||||||
|
|
||||||
|
@ -1293,9 +1293,7 @@ class MsG:
|
||||||
|
|
||||||
@_get_favorite.command(name='tags', aliases=['t'])
|
@_get_favorite.command(name='tags', aliases=['t'])
|
||||||
async def __get_favorite_tags(self, ctx, *args):
|
async def __get_favorite_tags(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
await ctx.send('\N{WHITE MEDIUM STAR} {}**\'s favorite tags:**\n```\n{}```'.format(ctx.author.mention, ' '.join(self.favorites.get(ctx.author.id, {}).get('tags', set()))))
|
||||||
|
|
||||||
await dest.send('\N{WHITE MEDIUM STAR} {}**\'s favorite tags:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(self.favorites.get(ctx.author.id, {}).get('tags', set()))))
|
|
||||||
|
|
||||||
@_get_favorite.command(name='posts', aliases=['p'])
|
@_get_favorite.command(name='posts', aliases=['p'])
|
||||||
async def __get_favorite_posts(self, ctx):
|
async def __get_favorite_posts(self, ctx):
|
||||||
|
@ -1309,7 +1307,7 @@ class MsG:
|
||||||
async def __add_favorite_tags(self, ctx, *args):
|
async def __add_favorite_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
if tag in self.blacklists['user_blacklist'].get(ctx.author.id, set()):
|
if tag in self.blacklists['user_blacklist'].get(ctx.author.id, set()):
|
||||||
|
@ -1322,7 +1320,7 @@ class MsG:
|
||||||
'tags', set()).update(tags)
|
'tags', set()).update(tags)
|
||||||
u.dump(self.favorites, 'cogs/favorites.pkl')
|
u.dump(self.favorites, 'cogs/favorites.pkl')
|
||||||
|
|
||||||
await dest.send('{} **added to their favorites:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(tags)))
|
await ctx.send('{} **added to their favorites:**\n```\n{}```'.format(ctx.author.mention, ' '.join(tags)))
|
||||||
|
|
||||||
except exc.BoundsError:
|
except exc.BoundsError:
|
||||||
await ctx.send('**Favorites list currently limited to:** `5`')
|
await ctx.send('**Favorites list currently limited to:** `5`')
|
||||||
|
@ -1343,7 +1341,7 @@ class MsG:
|
||||||
async def __remove_favorite_tags(self, ctx, *args):
|
async def __remove_favorite_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
|
@ -1355,7 +1353,7 @@ class MsG:
|
||||||
|
|
||||||
u.dump(self.favorites, 'cogs/favorites.pkl')
|
u.dump(self.favorites, 'cogs/favorites.pkl')
|
||||||
|
|
||||||
await dest.send('{} **removed from their favorites:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(tags)))
|
await ctx.send('{} **removed from their favorites:**\n```\n{}```'.format(ctx.author.mention, ' '.join(tags)))
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
await ctx.send('**You do not have any favorites**')
|
await ctx.send('**You do not have any favorites**')
|
||||||
|
@ -1374,13 +1372,11 @@ class MsG:
|
||||||
|
|
||||||
@_clear_favorite.command(name='tags', aliases=['t'])
|
@_clear_favorite.command(name='tags', aliases=['t'])
|
||||||
async def __clear_favorite_tags(self, ctx, *args):
|
async def __clear_favorite_tags(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
|
||||||
|
|
||||||
with suppress(KeyError):
|
with suppress(KeyError):
|
||||||
del self.favorites[ctx.author.id]
|
del self.favorites[ctx.author.id]
|
||||||
u.dump(self.favorites, 'cogs/favorites.pkl')
|
u.dump(self.favorites, 'cogs/favorites.pkl')
|
||||||
|
|
||||||
await dest.send('{}**\'s favorites cleared**'.format(ctx.author.mention))
|
await ctx.send('{}**\'s favorites cleared**'.format(ctx.author.mention))
|
||||||
|
|
||||||
@_clear_favorite.command(name='posts', aliases=['p'])
|
@_clear_favorite.command(name='posts', aliases=['p'])
|
||||||
async def __clear_favorite_posts(self, ctx):
|
async def __clear_favorite_posts(self, ctx):
|
||||||
|
@ -1426,33 +1422,25 @@ class MsG:
|
||||||
|
|
||||||
@_get_blacklist.command(name='global', aliases=['gl', 'g'], brief='Get current global blacklist', description='Get current global blacklist\n\nThis applies to all booru commands, in accordance with Discord\'s ToS agreement\n\nExample:\n\{p\}bl get global')
|
@_get_blacklist.command(name='global', aliases=['gl', 'g'], brief='Get current global blacklist', description='Get current global blacklist\n\nThis applies to all booru commands, in accordance with Discord\'s ToS agreement\n\nExample:\n\{p\}bl get global')
|
||||||
async def __get_global_blacklist(self, ctx, *args):
|
async def __get_global_blacklist(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
await ctx.send('\N{NO ENTRY SIGN} **Global blacklist:**\n```\n{}```'.format(' '.join(self.blacklists['global_blacklist'])))
|
||||||
|
|
||||||
await dest.send('\N{NO ENTRY SIGN} **Global blacklist:**\n```\n{}```'.format(formatter.tostring(self.blacklists['global_blacklist'])))
|
|
||||||
|
|
||||||
@_get_blacklist.command(name='channel', aliases=['ch', 'c'], brief='Get current channel blacklist', description='Get current channel blacklist\n\nThis is based on context - the channel where the command was executed\n\nExample:\{p\}bl get channel')
|
@_get_blacklist.command(name='channel', aliases=['ch', 'c'], brief='Get current channel blacklist', description='Get current channel blacklist\n\nThis is based on context - the channel where the command was executed\n\nExample:\{p\}bl get channel')
|
||||||
async def __get_channel_blacklist(self, ctx, *args):
|
async def __get_channel_blacklist(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
|
||||||
await dest.send('\N{NO ENTRY SIGN} {} **blacklist:**\n```\n{}```'.format(ctx.channel.mention, formatter.tostring(self.blacklists['guild_blacklist'].get(guild.id, {}).get(ctx.channel.id, set()))))
|
await ctx.send('\N{NO ENTRY SIGN} {} **blacklist:**\n```\n{}```'.format(ctx.channel.mention, ' '.join(self.blacklists['guild_blacklist'].get(guild.id, {}).get(ctx.channel.id, set()))))
|
||||||
|
|
||||||
@_get_blacklist.command(name='me', aliases=['m'], brief='Get your personal blacklist', description='Get your personal blacklist\n\nYour blacklist is not viewable by anyone but you, except if you call this command in a public channel. The blacklist will be deleted soon after for your privacy\n\nExample:\n\{p\}bl get me')
|
@_get_blacklist.command(name='me', aliases=['m'], brief='Get your personal blacklist', description='Get your personal blacklist\n\nYour blacklist is not viewable by anyone but you, except if you call this command in a public channel. The blacklist will be deleted soon after for your privacy\n\nExample:\n\{p\}bl get me')
|
||||||
async def __get_user_blacklist(self, ctx, *args):
|
async def __get_user_blacklist(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
await ctx.send('\N{NO ENTRY SIGN} {}**\'s blacklist:**\n```\n{}```'.format(ctx.author.mention, ' '.join(self.blacklists['user_blacklist'].get(ctx.author.id, set()))))
|
||||||
|
|
||||||
await dest.send('\N{NO ENTRY SIGN} {}**\'s blacklist:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(self.blacklists['user_blacklist'].get(ctx.author.id, set()))))
|
|
||||||
|
|
||||||
@_get_blacklist.command(name='here', aliases=['h'], brief='Get current global and channel blacklists', description='Get current global and channel blacklists in a single message\n\nExample:\{p\}bl get here')
|
@_get_blacklist.command(name='here', aliases=['h'], brief='Get current global and channel blacklists', description='Get current global and channel blacklists in a single message\n\nExample:\{p\}bl get here')
|
||||||
async def __get_here_blacklists(self, ctx, *args):
|
async def __get_here_blacklists(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
|
||||||
await dest.send('\N{NO ENTRY SIGN} **__Blacklisted:__**\n\n**Global:**\n```\n{}```\n**{}:**\n```\n{}```'.format(formatter.tostring(self.blacklists['global_blacklist']), ctx.channel.mention, formatter.tostring(self.blacklists['guild_blacklist'].get(guild.id, {}).get(ctx.channel.id, set()))))
|
await ctx.send('\N{NO ENTRY SIGN} **__Blacklisted:__**\n\n**Global:**\n```\n{}```\n**{}:**\n```\n{}```'.format(' '.join(self.blacklists['global_blacklist']), ctx.channel.mention, ' '.join(self.blacklists['guild_blacklist'].get(guild.id, {}).get(ctx.channel.id, set()))))
|
||||||
|
|
||||||
@_get_blacklist.group(name='all', aliases=['a'], hidden=True)
|
@_get_blacklist.group(name='all', aliases=['a'], hidden=True)
|
||||||
async def __get_all_blacklists(self, ctx):
|
async def __get_all_blacklists(self, ctx):
|
||||||
|
@ -1558,65 +1546,62 @@ class MsG:
|
||||||
@cmds.is_owner()
|
@cmds.is_owner()
|
||||||
async def __add_global_tags(self, ctx, *args):
|
async def __add_global_tags(self, ctx, *args):
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await dest.trigger_typing()
|
async with ctx.channel.typing():
|
||||||
|
tags = await self._aliases(ctx, tags, self.blacklists['global_blacklist'])
|
||||||
|
|
||||||
tags = await self._aliases(dest, tags, self.blacklists['global_blacklist'])
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
await ctx.send('\N{WHITE HEAVY CHECK MARK} **Added to global blacklist:**\n```\n{}```'.format(' '.join(tags)))
|
||||||
|
|
||||||
await dest.send('**Added to global blacklist:**\n```\n{}```'.format(formatter.tostring(tags)))
|
|
||||||
|
|
||||||
except exc.Abort:
|
except exc.Abort:
|
||||||
await dest.send('**Aborted**')
|
await ctx.send('**Aborted**')
|
||||||
except exc.MissingArgument:
|
except exc.MissingArgument:
|
||||||
await dest.send('\N{CROSS MARK} **Missing tags**')
|
await ctx.send('\N{CROSS MARK} **Missing tags**')
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
@_add_tags.command(name='channel', aliases=['ch', 'c'], brief='@manage_channel@ Add tag(s) to the current channel blacklist (requires manage_channel)', description='Add tag(s) to the current channel blacklist ')
|
@_add_tags.command(name='channel', aliases=['ch', 'c'], brief='@manage_channel@ Add tag(s) to the current channel blacklist (requires manage_channel)', description='Add tag(s) to the current channel blacklist ')
|
||||||
@cmds.has_permissions(manage_channels=True)
|
@cmds.has_permissions(manage_channels=True)
|
||||||
async def __add_channel_tags(self, ctx, *args):
|
async def __add_channel_tags(self, ctx, *args):
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await dest.trigger_typing()
|
async with ctx.channel.typing():
|
||||||
|
tags = await self._aliases(ctx, tags, self.blacklists['guild_blacklist'].setdefault(guild.id, {}).setdefault(ctx.channel.id, set()))
|
||||||
|
|
||||||
tags = await self._aliases(dest, tags, self.blacklists['guild_blacklist'].setdefault(guild.id, {}).setdefault(ctx.channel.id, set()))
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
await ctx.send('\N{WHITE HEAVY CHECK MARK} **Added to** {} **blacklist:**\n```\n{}```'.format(ctx.channel.mention, ' '.join(tags)))
|
||||||
|
|
||||||
await dest.send('**Added to** {} **blacklist:**\n```\n{}```'.format(ctx.channel.mention, formatter.tostring(tags)))
|
|
||||||
|
|
||||||
except exc.Abort:
|
except exc.Abort:
|
||||||
await dest.send('**Aborted**')
|
await ctx.send('**Aborted**')
|
||||||
except exc.MissingArgument:
|
except exc.MissingArgument:
|
||||||
await dest.send('\N{CROSS MARK} **Missing tags**')
|
await ctx.send('\N{CROSS MARK} **Missing tags**')
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
@_add_tags.command(name='me', aliases=['m'])
|
@_add_tags.command(name='me', aliases=['m'])
|
||||||
async def __add_user_tags(self, ctx, *args):
|
async def __add_user_tags(self, ctx, *args):
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await dest.trigger_typing()
|
async with ctx.channel.typing():
|
||||||
|
tags = await self._aliases(ctx, tags, self.blacklists['user_blacklist'].setdefault(ctx.author.id, set()))
|
||||||
|
|
||||||
tags = await self._aliases(dest, tags, self.blacklists['user_blacklist'].setdefault(ctx.author.id, set()))
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
await ctx.send('\N{WHITE HEAVY CHECK MARK} {} **added to their blacklist:**\n```\n{}```'.format(ctx.author.mention, ' '.join(tags)))
|
||||||
|
|
||||||
await dest.send('{} **added to their blacklist:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(tags)))
|
|
||||||
|
|
||||||
except exc.Abort:
|
except exc.Abort:
|
||||||
await dest.send('**Aborted**')
|
await ctx.send('**Aborted**')
|
||||||
except exc.MissingArgument:
|
except exc.MissingArgument:
|
||||||
await dest.send('\N{CROSS MARK} **Missing tags**')
|
await ctx.send('\N{CROSS MARK} **Missing tags**')
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
@blacklist.group(name='remove', aliases=['rm', 'r'])
|
@blacklist.group(name='remove', aliases=['rm', 'r'])
|
||||||
|
@ -1630,7 +1615,7 @@ class MsG:
|
||||||
async def __remove_global_tags(self, ctx, *args):
|
async def __remove_global_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
|
@ -1641,7 +1626,7 @@ class MsG:
|
||||||
|
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
await dest.send('**Removed from global blacklist:**\n```\n{}```'.format(formatter.tostring(tags)))
|
await ctx.send('**Removed from global blacklist:**\n```\n{}```'.format(' '.join(tags)))
|
||||||
|
|
||||||
except exc.TagError as e:
|
except exc.TagError as e:
|
||||||
await ctx.send('`{}` **not in blacklist**'.format(e))
|
await ctx.send('`{}` **not in blacklist**'.format(e))
|
||||||
|
@ -1652,7 +1637,7 @@ class MsG:
|
||||||
async def __remove_channel_tags(self, ctx, *args):
|
async def __remove_channel_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
@ -1667,7 +1652,7 @@ class MsG:
|
||||||
|
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
await dest.send('**Removed from** {} **blacklist:**\n```\n{}```'.format(ctx.channel.mention, formatter.tostring(tags)))
|
await ctx.send('**Removed from** {} **blacklist:**\n```\n{}```'.format(ctx.channel.mention, ' '.join(tags)))
|
||||||
|
|
||||||
except exc.TagError as e:
|
except exc.TagError as e:
|
||||||
await ctx.send('`{}` **not in blacklist**'.format(e))
|
await ctx.send('`{}` **not in blacklist**'.format(e))
|
||||||
|
@ -1677,7 +1662,7 @@ class MsG:
|
||||||
async def __remove_user_tags(self, ctx, *args):
|
async def __remove_user_tags(self, ctx, *args):
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
tags = kwargs['remaining']
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
try:
|
try:
|
||||||
|
@ -1689,7 +1674,7 @@ class MsG:
|
||||||
|
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
await dest.send('{} **removed from their blacklist:**\n```\n{}```'.format(ctx.author.mention, formatter.tostring(tags)))
|
await ctx.send('{} **removed from their blacklist:**\n```\n{}```'.format(ctx.author.mention, ' '.join(tags)))
|
||||||
|
|
||||||
except exc.TagError as e:
|
except exc.TagError as e:
|
||||||
await ctx.send('`{}` **not in blacklist**'.format(e))
|
await ctx.send('`{}` **not in blacklist**'.format(e))
|
||||||
|
@ -1704,18 +1689,14 @@ class MsG:
|
||||||
@_clear_blacklist.command(name='global', aliases=['gl', 'g'])
|
@_clear_blacklist.command(name='global', aliases=['gl', 'g'])
|
||||||
@cmds.is_owner()
|
@cmds.is_owner()
|
||||||
async def __clear_global_blacklist(self, ctx, *args):
|
async def __clear_global_blacklist(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
|
||||||
|
|
||||||
self.blacklists['global_blacklist'].clear()
|
self.blacklists['global_blacklist'].clear()
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
await dest.send('**Global blacklist cleared**')
|
await ctx.send('**Global blacklist cleared**')
|
||||||
|
|
||||||
@_clear_blacklist.command(name='channel', aliases=['ch', 'c'])
|
@_clear_blacklist.command(name='channel', aliases=['ch', 'c'])
|
||||||
@cmds.has_permissions(manage_channels=True)
|
@cmds.has_permissions(manage_channels=True)
|
||||||
async def __clear_channel_blacklist(self, ctx, *args):
|
async def __clear_channel_blacklist(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
|
||||||
|
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
|
||||||
|
@ -1723,14 +1704,12 @@ class MsG:
|
||||||
del self.blacklists['guild_blacklist'][guild.id][ctx.channel.id]
|
del self.blacklists['guild_blacklist'][guild.id][ctx.channel.id]
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
await dest.send('{} **blacklist cleared**'.format(ctx.channel.mention))
|
await ctx.send('{} **blacklist cleared**'.format(ctx.channel.mention))
|
||||||
|
|
||||||
@_clear_blacklist.command(name='me', aliases=['m'])
|
@_clear_blacklist.command(name='me', aliases=['m'])
|
||||||
async def __clear_user_blacklist(self, ctx, *args):
|
async def __clear_user_blacklist(self, ctx, *args):
|
||||||
dest = u.get_kwargs(ctx, args)['destination']
|
|
||||||
|
|
||||||
with suppress(KeyError):
|
with suppress(KeyError):
|
||||||
del self.blacklists['user_blacklist'][ctx.author.id]
|
del self.blacklists['user_blacklist'][ctx.author.id]
|
||||||
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
u.dump(self.blacklists, 'cogs/blacklists.pkl')
|
||||||
|
|
||||||
await dest.send('{}**\'s blacklist cleared**'.format(ctx.author.mention))
|
await ctx.send('{}**\'s blacklist cleared**'.format(ctx.author.mention))
|
||||||
|
|
12
src/run.py
12
src/run.py
|
@ -91,10 +91,10 @@ async def on_ready():
|
||||||
if u.temp['startup']:
|
if u.temp['startup']:
|
||||||
with suppress(err.NotFound):
|
with suppress(err.NotFound):
|
||||||
if u.temp['startup'][0] == 'guild':
|
if u.temp['startup'][0] == 'guild':
|
||||||
dest = bot.get_channel(u.temp['startup'][1])
|
ctx = bot.get_channel(u.temp['startup'][1])
|
||||||
else:
|
else:
|
||||||
dest = bot.get_user(u.temp['startup'][1])
|
ctx = bot.get_user(u.temp['startup'][1])
|
||||||
message = await dest.get_message(u.temp['startup'][2])
|
message = await ctx.get_message(u.temp['startup'][2])
|
||||||
|
|
||||||
await message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
await message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
|
|
||||||
|
@ -144,10 +144,10 @@ async def on_error(error, *args, **kwargs):
|
||||||
if u.temp['startup']:
|
if u.temp['startup']:
|
||||||
with suppress(err.NotFound):
|
with suppress(err.NotFound):
|
||||||
if u.temp['startup'][0] == 'guild':
|
if u.temp['startup'][0] == 'guild':
|
||||||
dest = bot.get_channel(u.temp['startup'][1])
|
ctx = bot.get_channel(u.temp['startup'][1])
|
||||||
else:
|
else:
|
||||||
dest = bot.get_user(u.temp['startup'][1])
|
ctx = bot.get_user(u.temp['startup'][1])
|
||||||
message = await dest.get_message(u.temp['startup'][2])
|
message = await ctx.get_message(u.temp['startup'][2])
|
||||||
|
|
||||||
await message.add_reaction('\N{WARNING SIGN}')
|
await message.add_reaction('\N{WARNING SIGN}')
|
||||||
|
|
||||||
|
|
|
@ -132,17 +132,10 @@ def generate_embed(ctx, *, title=d.Embed.Empty, kind='rich', description=d.Embed
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
def get_kwargs(ctx, args, *, limit=False):
|
def get_kwargs(ctx, args, *, limit=False):
|
||||||
destination = ctx
|
|
||||||
remaining = list(args[:])
|
remaining = list(args[:])
|
||||||
rm = False
|
rm = False
|
||||||
lim = 1
|
lim = 1
|
||||||
|
|
||||||
for flag in ('-dm', '-pm', '--message'):
|
|
||||||
if flag in remaining:
|
|
||||||
destination = ctx.author
|
|
||||||
|
|
||||||
remaining.remove(flag)
|
|
||||||
|
|
||||||
for flag in ('-r', '-rm', '--remove'):
|
for flag in ('-r', '-rm', '--remove'):
|
||||||
if flag in remaining and ctx.author.permissions_in(ctx.channel).manage_messages:
|
if flag in remaining and ctx.author.permissions_in(ctx.channel).manage_messages:
|
||||||
rm = True
|
rm = True
|
||||||
|
@ -159,7 +152,7 @@ def get_kwargs(ctx, args, *, limit=False):
|
||||||
else:
|
else:
|
||||||
raise exc.BoundsError(arg)
|
raise exc.BoundsError(arg)
|
||||||
|
|
||||||
return {'destination': destination, 'remaining': remaining, 'remove': rm, 'limit': lim}
|
return {'remaining': remaining, 'remove': rm, 'limit': lim}
|
||||||
|
|
||||||
|
|
||||||
def get_aspectratio(a, b):
|
def get_aspectratio(a, b):
|
||||||
|
|
Loading…
Reference in a new issue