mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 21:02:38 +00:00
Add remove flag to reverse command
This commit is contained in:
parent
fc1d00eff0
commit
e96d98aee8
1 changed files with 21 additions and 17 deletions
|
@ -239,10 +239,10 @@ class MsG:
|
||||||
for rel in tag_request.get(tag, []):
|
for rel in tag_request.get(tag, []):
|
||||||
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 dest.send('`{}` **related tags:**\n```\n{}```'.format(tag, formatter.tostring(related)))
|
||||||
else:
|
else:
|
||||||
await ctx.send(f'**No related tags found for:** `{tag}`', delete_after=7)
|
await ctx.send(f'**No related tags found for:** `{tag}`', delete_after=7)
|
||||||
|
|
||||||
related.clear()
|
related.clear()
|
||||||
c += 1
|
c += 1
|
||||||
|
@ -265,10 +265,10 @@ class MsG:
|
||||||
for dic in alias_request:
|
for dic in alias_request:
|
||||||
aliases.append(dic['name'])
|
aliases.append(dic['name'])
|
||||||
|
|
||||||
if aliases:
|
if aliases:
|
||||||
await dest.send('`{}` **aliases:**\n```\n{}```'.format(tag, formatter.tostring(aliases)))
|
await dest.send('`{}` **aliases:**\n```\n{}```'.format(tag, formatter.tostring(aliases)))
|
||||||
else:
|
else:
|
||||||
await ctx.send(f'**No aliases found for:** `{tag}`', delete_after=7)
|
await ctx.send(f'**No aliases found for:** `{tag}`', delete_after=7)
|
||||||
|
|
||||||
aliases.clear()
|
aliases.clear()
|
||||||
c += 1
|
c += 1
|
||||||
|
@ -295,14 +295,14 @@ class MsG:
|
||||||
await dest.trigger_typing()
|
await dest.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)
|
||||||
post = await u.fetch('https://e621.net/post/show.json', params={'id': ident}, json=True)
|
post = await u.fetch('https://e621.net/post/show.json', params={'id': ident}, json=True)
|
||||||
|
|
||||||
embed = d.Embed(
|
embed = d.Embed(
|
||||||
title=', '.join(post['artist']), url=f'https://e621.net/post/show/{post["id"]}', color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else u.color)
|
title=', '.join(post['artist']), url=f'https://e621.net/post/show/{post["id"]}', color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else u.color)
|
||||||
embed.set_thumbnail(url=post['file_url'])
|
embed.set_thumbnail(url=post['file_url'])
|
||||||
embed.set_author(name=f'{post["width"]} x {post["height"]}',
|
embed.set_author(name=f'{post["width"]} x {post["height"]}',
|
||||||
url=f'https://e621.net/post?tags=ratio:{post["width"]/post["height"]:.2f}', icon_url=ctx.author.avatar_url)
|
url=f'https://e621.net/post?tags=ratio:{post["width"]/post["height"]:.2f}', icon_url=ctx.author.avatar_url)
|
||||||
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']))
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ class MsG:
|
||||||
|
|
||||||
await dest.send(await scraper.get_image(url))
|
await dest.send(await scraper.get_image(url))
|
||||||
|
|
||||||
c += 1
|
c += 1
|
||||||
|
|
||||||
# except
|
# except
|
||||||
# await ctx.send(f'**No aliases found for:** `{tag}`', delete_after=7)
|
# await ctx.send(f'**No aliases found for:** `{tag}`', delete_after=7)
|
||||||
|
@ -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 = kwargs['destination'], kwargs['remaining']
|
dest, urls, remove = kwargs['destination'], kwargs['remaining'], kwargs['remove']
|
||||||
c = 0
|
c = 0
|
||||||
|
|
||||||
if not urls and not ctx.message.attachments:
|
if not urls and not ctx.message.attachments:
|
||||||
|
@ -418,6 +418,10 @@ class MsG:
|
||||||
except exc.MatchError as e:
|
except exc.MatchError as e:
|
||||||
await ctx.send('**No probable match for:** `{}`'.format(e), delete_after=7)
|
await ctx.send('**No probable match for:** `{}`'.format(e), delete_after=7)
|
||||||
|
|
||||||
|
if remove:
|
||||||
|
with suppress(err.NotFound):
|
||||||
|
await ctx.message.delete()
|
||||||
|
|
||||||
if not c:
|
if not c:
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue