mirror of
https://github.com/myned/modufur.git
synced 2024-12-25 06:37:29 +00:00
Removed owner global access to paginator, starred > hearted, ordering
This commit is contained in:
parent
f96b5270c9
commit
f121ccd3f8
1 changed files with 126 additions and 99 deletions
|
@ -516,15 +516,15 @@ class MsG:
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
async def pool_paginator(self, ctx, *args):
|
async def pool_paginator(self, ctx, *args):
|
||||||
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 or user.id == u.config['owner_id']):
|
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and user is ctx.author:
|
||||||
raise exc.Abort
|
raise exc.Abort
|
||||||
elif reaction.emoji == '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}' and reaction.message.id == paginator.id and (user is ctx.author or user.id == u.config['owner_id']):
|
elif reaction.emoji == '\N{GROWING HEART}' and reaction.message.id == paginator.id and user is ctx.author:
|
||||||
raise exc.GoTo
|
|
||||||
elif reaction.emoji == '\N{LEFTWARDS BLACK ARROW}' and reaction.message.id == paginator.id and (user is ctx.author or user.id == u.config['owner_id']):
|
|
||||||
raise exc.Left
|
|
||||||
elif reaction.emoji == '\N{GROWING HEART}' and reaction.message.id == paginator.id and (user is ctx.author or user.id == u.config['owner_id']):
|
|
||||||
raise exc.Save
|
raise exc.Save
|
||||||
elif reaction.emoji == '\N{BLACK RIGHTWARDS ARROW}' and reaction.message.id == paginator.id and (user is ctx.author or user.id == u.config['owner_id']):
|
elif reaction.emoji == '\N{LEFTWARDS BLACK ARROW}' and reaction.message.id == paginator.id and user is ctx.author:
|
||||||
|
raise exc.Left
|
||||||
|
elif reaction.emoji == '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}' and reaction.message.id == paginator.id and user is ctx.author:
|
||||||
|
raise exc.GoTo
|
||||||
|
elif reaction.emoji == '\N{BLACK RIGHTWARDS ARROW}' and reaction.message.id == paginator.id and user is ctx.author:
|
||||||
raise exc.Right
|
raise exc.Right
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -537,12 +537,12 @@ class MsG:
|
||||||
try:
|
try:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, query = kwargs['destination'], kwargs['remaining']
|
dest, query = kwargs['destination'], kwargs['remaining']
|
||||||
starred = []
|
hearted = []
|
||||||
c = 1
|
c = 1
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
|
||||||
pool, posts = await self.return_pool(ctx, 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())
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ class MsG:
|
||||||
|
|
||||||
paginator = await dest.send(embed=embed)
|
paginator = await dest.send(embed=embed)
|
||||||
|
|
||||||
for emoji in ('\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}', '\N{LEFTWARDS BLACK ARROW}', '\N{GROWING HEART}', '\N{BLACK RIGHTWARDS ARROW}'):
|
for emoji in ('\N{GROWING 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)
|
||||||
await ctx.message.add_reaction('\N{OCTAGONAL SIGN}')
|
await ctx.message.add_reaction('\N{OCTAGONAL SIGN}')
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
@ -568,6 +568,29 @@ class MsG:
|
||||||
for future in done:
|
for future in done:
|
||||||
future.result()
|
future.result()
|
||||||
|
|
||||||
|
except exc.Save:
|
||||||
|
if values[c - 1]['url'] not in hearted:
|
||||||
|
hearted.append(values[c - 1]['url'])
|
||||||
|
|
||||||
|
await paginator.edit(content='\N{HEAVY BLACK HEART}')
|
||||||
|
else:
|
||||||
|
hearted.remove(values[c - 1]['url'])
|
||||||
|
|
||||||
|
await paginator.edit(content='\N{BROKEN HEART}')
|
||||||
|
|
||||||
|
except exc.Left:
|
||||||
|
if c > 1:
|
||||||
|
c -= 1
|
||||||
|
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://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
||||||
|
embed.set_image(url=values[c - 1]['url'])
|
||||||
|
|
||||||
|
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in hearted else None, embed=embed)
|
||||||
|
else:
|
||||||
|
await paginator.edit(content='**First image.**')
|
||||||
|
|
||||||
except exc.GoTo:
|
except exc.GoTo:
|
||||||
await paginator.edit(content='**Enter image number...**')
|
await paginator.edit(content='**Enter image number...**')
|
||||||
number = await self.bot.wait_for('message', check=on_message, timeout=10 * 60)
|
number = await self.bot.wait_for('message', check=on_message, timeout=10 * 60)
|
||||||
|
@ -580,30 +603,7 @@ class MsG:
|
||||||
icon_url='http://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
icon_url='http://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
||||||
embed.set_image(url=values[c - 1]['url'])
|
embed.set_image(url=values[c - 1]['url'])
|
||||||
|
|
||||||
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in starred else None, embed=embed)
|
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in hearted else None, embed=embed)
|
||||||
|
|
||||||
except exc.Left:
|
|
||||||
if c > 1:
|
|
||||||
c -= 1
|
|
||||||
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://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
|
||||||
embed.set_image(url=values[c - 1]['url'])
|
|
||||||
|
|
||||||
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in starred else None, embed=embed)
|
|
||||||
else:
|
|
||||||
await paginator.edit(content='**First image.**')
|
|
||||||
|
|
||||||
except exc.Save:
|
|
||||||
if values[c - 1]['url'] not in starred:
|
|
||||||
starred.append(values[c - 1]['url'])
|
|
||||||
|
|
||||||
await paginator.edit(content='\N{HEAVY BLACK HEART}')
|
|
||||||
else:
|
|
||||||
starred.remove(values[c - 1]['url'])
|
|
||||||
|
|
||||||
await paginator.edit(content='\N{BROKEN HEART}')
|
|
||||||
|
|
||||||
except exc.Right:
|
except exc.Right:
|
||||||
if c < len(keys):
|
if c < len(keys):
|
||||||
|
@ -614,7 +614,9 @@ class MsG:
|
||||||
icon_url='http://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
icon_url='http://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
||||||
embed.set_image(url=values[c - 1]['url'])
|
embed.set_image(url=values[c - 1]['url'])
|
||||||
|
|
||||||
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in starred else None, embed=embed)
|
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in hearted else None, embed=embed)
|
||||||
|
else:
|
||||||
|
await paginator.edit(content='**Last image.**')
|
||||||
|
|
||||||
except exc.Abort:
|
except exc.Abort:
|
||||||
try:
|
try:
|
||||||
|
@ -622,12 +624,16 @@ class MsG:
|
||||||
|
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('**Exited paginator.**')
|
await dest.send('**Exited paginator.**')
|
||||||
|
if not hearted:
|
||||||
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
try:
|
try:
|
||||||
await paginator.edit(content='**Paginator timed out.**')
|
await paginator.edit(content='**Paginator timed out.**')
|
||||||
|
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('**Paginator timed out.**')
|
await dest.send('**Paginator timed out.**')
|
||||||
|
if not hearted:
|
||||||
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
except exc.NotFound:
|
except exc.NotFound:
|
||||||
await ctx.send('**Pool not found.**', delete_after=10)
|
await ctx.send('**Pool not found.**', delete_after=10)
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
@ -636,18 +642,18 @@ class MsG:
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if starred:
|
if hearted:
|
||||||
await ctx.message.add_reaction('\N{HOURGLASS WITH FLOWING SAND}')
|
await ctx.message.add_reaction('\N{HOURGLASS WITH FLOWING SAND}')
|
||||||
|
|
||||||
for url in starred:
|
for url in hearted:
|
||||||
await ctx.author.send('`{} / {}`\n{}'.format(starred.index(url) + 1, len(starred), url))
|
await ctx.author.send('`{} / {}`\n{}'.format(hearted.index(url) + 1, len(hearted), url))
|
||||||
if len(starred) > 5:
|
|
||||||
await asyncio.sleep(self.RATE_LIMIT)
|
await asyncio.sleep(self.RATE_LIMIT)
|
||||||
|
|
||||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
|
|
||||||
# Messy code that checks image limit and tags in blacklists
|
# Messy code that checks image limit and tags in blacklists
|
||||||
async def check_return_posts(self, ctx, *, booru='e621', tags=[], limit=1, previous={}):
|
async def _get_posts(self, ctx, *, booru='e621', tags=[], limit=1, previous={}):
|
||||||
guild = ctx.guild if isinstance(
|
guild = ctx.guild if isinstance(
|
||||||
ctx.guild, d.Guild) else ctx.channel
|
ctx.guild, d.Guild) else ctx.channel
|
||||||
|
|
||||||
|
@ -669,6 +675,8 @@ class MsG:
|
||||||
|
|
||||||
# Checks for blacklisted tags in endpoint blacklists - try/except is for continuing the parent loop
|
# Checks for blacklisted tags in endpoint blacklists - try/except is for continuing the parent loop
|
||||||
posts = {}
|
posts = {}
|
||||||
|
temposts = len(posts)
|
||||||
|
empty = 0
|
||||||
c = 0
|
c = 0
|
||||||
while len(posts) < limit:
|
while len(posts) < limit:
|
||||||
if c == limit * 5 + self.LIMIT:
|
if c == limit * 5 + self.LIMIT:
|
||||||
|
@ -692,24 +700,35 @@ class MsG:
|
||||||
posts[post['id']] = {'author': post['author'], 'url': post['file_url']}
|
posts[post['id']] = {'author': post['author'], 'url': post['file_url']}
|
||||||
if len(posts) == limit:
|
if len(posts) == limit:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if len(posts) == temposts:
|
||||||
|
empty += 1
|
||||||
|
if empty == 5:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
empty = 0
|
||||||
|
temposts = len(posts)
|
||||||
c += 1
|
c += 1
|
||||||
|
|
||||||
|
if posts:
|
||||||
return posts
|
return posts
|
||||||
|
else:
|
||||||
|
raise exc.NotFound
|
||||||
|
|
||||||
@commands.command(name='e621p', aliases=['e6p', '6p'])
|
@commands.command(name='e621p', aliases=['e6p', '6p'])
|
||||||
@checks.del_ctx()
|
@checks.del_ctx()
|
||||||
@checks.is_nsfw()
|
@checks.is_nsfw()
|
||||||
async def e621_paginator(self, ctx, *args):
|
async def e621_paginator(self, ctx, *args):
|
||||||
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 or user.id == u.config['owner_id']):
|
if reaction.emoji == '\N{OCTAGONAL SIGN}' and reaction.message.id == ctx.message.id and user is ctx.author:
|
||||||
raise exc.Abort
|
raise exc.Abort
|
||||||
elif reaction.emoji == '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}' and reaction.message.id == paginator.id and (user is ctx.author or user.id == u.config['owner_id']):
|
elif reaction.emoji == '\N{GROWING HEART}' and reaction.message.id == paginator.id and user is ctx.author:
|
||||||
raise exc.GoTo
|
|
||||||
elif reaction.emoji == '\N{LEFTWARDS BLACK ARROW}' and reaction.message.id == paginator.id and (user is ctx.author or user.id == u.config['owner_id']):
|
|
||||||
raise exc.Left
|
|
||||||
elif reaction.emoji == '\N{GROWING HEART}' and reaction.message.id == paginator.id and (user is ctx.author or user.id == u.config['owner_id']):
|
|
||||||
raise exc.Save
|
raise exc.Save
|
||||||
elif reaction.emoji == '\N{BLACK RIGHTWARDS ARROW}' and reaction.message.id == paginator.id and (user is ctx.author or user.id == u.config['owner_id']):
|
elif reaction.emoji == '\N{LEFTWARDS BLACK ARROW}' and reaction.message.id == paginator.id and user is ctx.author:
|
||||||
|
raise exc.Left
|
||||||
|
elif reaction.emoji == '\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}' and reaction.message.id == paginator.id and user is ctx.author:
|
||||||
|
raise exc.GoTo
|
||||||
|
elif reaction.emoji == '\N{BLACK RIGHTWARDS ARROW}' and reaction.message.id == paginator.id and user is ctx.author:
|
||||||
raise exc.Right
|
raise exc.Right
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -723,14 +742,14 @@ class MsG:
|
||||||
kwargs = u.get_kwargs(ctx, args)
|
kwargs = u.get_kwargs(ctx, args)
|
||||||
dest, tags = kwargs['destination'], kwargs['remaining']
|
dest, tags = kwargs['destination'], kwargs['remaining']
|
||||||
limit = self.LIMIT / 5
|
limit = self.LIMIT / 5
|
||||||
starred = []
|
hearted = []
|
||||||
c = 1
|
c = 1
|
||||||
|
|
||||||
tags = self.get_favorites(ctx, tags)
|
tags = self._get_favorites(ctx, tags)
|
||||||
|
|
||||||
await ctx.trigger_typing()
|
await ctx.trigger_typing()
|
||||||
|
|
||||||
posts = await self.check_return_posts(ctx, booru='e621', tags=tags, limit=limit)
|
posts = await self._get_posts(ctx, booru='e621', tags=tags, limit=limit)
|
||||||
keys = list(posts.keys())
|
keys = list(posts.keys())
|
||||||
values = list(posts.values())
|
values = list(posts.values())
|
||||||
|
|
||||||
|
@ -744,7 +763,7 @@ class MsG:
|
||||||
|
|
||||||
paginator = await dest.send(embed=embed)
|
paginator = await dest.send(embed=embed)
|
||||||
|
|
||||||
for emoji in ('\N{NUMBER SIGN}\N{COMBINING ENCLOSING KEYCAP}', '\N{LEFTWARDS BLACK ARROW}', '\N{GROWING HEART}', '\N{BLACK RIGHTWARDS ARROW}'):
|
for emoji in ('\N{GROWING 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)
|
||||||
await ctx.message.add_reaction('\N{OCTAGONAL SIGN}')
|
await ctx.message.add_reaction('\N{OCTAGONAL SIGN}')
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
@ -756,6 +775,29 @@ class MsG:
|
||||||
for future in done:
|
for future in done:
|
||||||
future.result()
|
future.result()
|
||||||
|
|
||||||
|
except exc.Save:
|
||||||
|
if values[c - 1]['url'] not in hearted:
|
||||||
|
hearted.append(values[c - 1]['url'])
|
||||||
|
|
||||||
|
await paginator.edit(content='\N{HEAVY BLACK HEART}')
|
||||||
|
else:
|
||||||
|
hearted.remove(values[c - 1]['url'])
|
||||||
|
|
||||||
|
await paginator.edit(content='\N{BROKEN HEART}')
|
||||||
|
|
||||||
|
except exc.Left:
|
||||||
|
if c > 1:
|
||||||
|
c -= 1
|
||||||
|
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://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
||||||
|
embed.set_image(url=values[c - 1]['url'])
|
||||||
|
|
||||||
|
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in hearted else None, embed=embed)
|
||||||
|
else:
|
||||||
|
await paginator.edit(content='**First image.**')
|
||||||
|
|
||||||
except exc.GoTo:
|
except exc.GoTo:
|
||||||
await paginator.edit(content='**Enter image number...**')
|
await paginator.edit(content='**Enter image number...**')
|
||||||
number = await self.bot.wait_for('message', check=on_message, timeout=10 * 60)
|
number = await self.bot.wait_for('message', check=on_message, timeout=10 * 60)
|
||||||
|
@ -768,38 +810,13 @@ class MsG:
|
||||||
icon_url='http://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
icon_url='http://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
||||||
embed.set_image(url=values[c - 1]['url'])
|
embed.set_image(url=values[c - 1]['url'])
|
||||||
|
|
||||||
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in starred else None, embed=embed)
|
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in hearted else None, embed=embed)
|
||||||
|
|
||||||
except exc.Left:
|
|
||||||
if c > 1:
|
|
||||||
c -= 1
|
|
||||||
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://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
|
||||||
embed.set_image(url=values[c - 1]['url'])
|
|
||||||
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in starred else None, embed=embed)
|
|
||||||
else:
|
|
||||||
await paginator.edit(content='**First image.**')
|
|
||||||
|
|
||||||
except exc.Save:
|
|
||||||
if values[c - 1]['url'] not in starred:
|
|
||||||
starred.append(values[c - 1]['url'])
|
|
||||||
|
|
||||||
await paginator.edit(content='\N{HEAVY BLACK HEART}')
|
|
||||||
else:
|
|
||||||
starred.remove(values[c - 1]['url'])
|
|
||||||
|
|
||||||
await paginator.edit(content='\N{BROKEN HEART}')
|
|
||||||
|
|
||||||
except exc.Right:
|
except exc.Right:
|
||||||
|
try:
|
||||||
if c % limit == 0:
|
if c % limit == 0:
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
try:
|
posts.update(await self._get_posts(ctx, booru='e621', tags=tags, limit=limit, previous=posts))
|
||||||
posts.update(await self.check_return_posts(ctx, booru='e621', tags=tags, limit=limit, previous=posts))
|
|
||||||
|
|
||||||
except exc.NotFound:
|
|
||||||
await paginator.edit(content='**No more images found.**')
|
|
||||||
|
|
||||||
keys = list(posts.keys())
|
keys = list(posts.keys())
|
||||||
values = list(posts.values())
|
values = list(posts.values())
|
||||||
|
@ -810,7 +827,13 @@ class MsG:
|
||||||
embed.set_footer(text='{} / {}'.format(c, len(posts)),
|
embed.set_footer(text='{} / {}'.format(c, len(posts)),
|
||||||
icon_url='http://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
icon_url='http://lh6.ggpht.com/d3pNZNFCcJM8snBsRSdKUhR9AVBnJMcYYrR92RRDBOzCrxZMhuTeoGOQSmSEn7DAPQ=w300')
|
||||||
embed.set_image(url=values[c - 1]['url'])
|
embed.set_image(url=values[c - 1]['url'])
|
||||||
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in starred else None, embed=embed)
|
|
||||||
|
await paginator.edit(content='\N{HEAVY BLACK HEART}' if values[c - 1]['url'] in hearted else None, embed=embed)
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
await paginator.edit(content='**No more images found.**')
|
||||||
|
except exc.NotFound:
|
||||||
|
await paginator.edit(content='**No more images found.**')
|
||||||
|
|
||||||
except exc.Abort:
|
except exc.Abort:
|
||||||
try:
|
try:
|
||||||
|
@ -818,12 +841,16 @@ class MsG:
|
||||||
|
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('**Exited paginator.**')
|
await dest.send('**Exited paginator.**')
|
||||||
|
if not hearted:
|
||||||
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
try:
|
try:
|
||||||
await paginator.edit(content='**Paginator timed out.**')
|
await paginator.edit(content='**Paginator timed out.**')
|
||||||
|
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
await dest.send('**Paginator timed out.**')
|
await dest.send('**Paginator timed out.**')
|
||||||
|
if not hearted:
|
||||||
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
except exc.NotFound as e:
|
except exc.NotFound as e:
|
||||||
await ctx.send('`{}` **not found.**'.format(e), delete_after=10)
|
await ctx.send('`{}` **not found.**'.format(e), delete_after=10)
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
@ -831,7 +858,7 @@ class MsG:
|
||||||
await ctx.send('\N{NO ENTRY SIGN} `{}` **blacklisted.**'.format(e), delete_after=10)
|
await ctx.send('\N{NO ENTRY SIGN} `{}` **blacklisted.**'.format(e), delete_after=10)
|
||||||
await ctx.message.add_reaction('\N{NO ENTRY SIGN}')
|
await ctx.message.add_reaction('\N{NO ENTRY SIGN}')
|
||||||
except exc.TagBoundsError as e:
|
except exc.TagBoundsError as e:
|
||||||
await ctx.send('`{}` **out of bounds.** Tags limited to 5, currently.'.format(e), delete_after=10)
|
await ctx.send('`{}` **out of bounds.** Tags limited to 5.'.format(e), delete_after=10)
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
except exc.FavoritesNotFound:
|
except exc.FavoritesNotFound:
|
||||||
await ctx.send('**You have no favorite tags.**', delete_after=10)
|
await ctx.send('**You have no favorite tags.**', delete_after=10)
|
||||||
|
@ -841,12 +868,12 @@ class MsG:
|
||||||
await ctx.message.add_reaction('\N{CROSS MARK}')
|
await ctx.message.add_reaction('\N{CROSS MARK}')
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if starred:
|
if hearted:
|
||||||
await ctx.message.add_reaction('\N{HOURGLASS WITH FLOWING SAND}')
|
await ctx.message.add_reaction('\N{HOURGLASS WITH FLOWING SAND}')
|
||||||
|
|
||||||
for url in starred:
|
for url in hearted:
|
||||||
await ctx.author.send('`{} / {}`\n{}'.format(starred.index(url) + 1, len(starred), url))
|
await ctx.author.send('`{} / {}`\n{}'.format(hearted.index(url) + 1, len(hearted), url))
|
||||||
if len(starred) > 5:
|
|
||||||
await asyncio.sleep(self.RATE_LIMIT)
|
await asyncio.sleep(self.RATE_LIMIT)
|
||||||
|
|
||||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||||
|
@ -866,11 +893,11 @@ class MsG:
|
||||||
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']
|
dest, args, limit = kwargs['destination'], kwargs['remaining'], kwargs['limit']
|
||||||
|
|
||||||
tags = self.get_favorites(ctx, args)
|
tags = self._get_favorites(ctx, args)
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
|
||||||
posts = await self.check_return_posts(ctx, booru='e621', tags=tags, limit=limit)
|
posts = await self._get_posts(ctx, booru='e621', tags=tags, limit=limit)
|
||||||
|
|
||||||
for ident, post in posts.items():
|
for ident, post in posts.items():
|
||||||
embed = d.Embed(title=post['author'], url='https://e621.net/post/show/{}'.format(ident),
|
embed = d.Embed(title=post['author'], url='https://e621.net/post/show/{}'.format(ident),
|
||||||
|
@ -920,11 +947,11 @@ class MsG:
|
||||||
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']
|
dest, args, limit = kwargs['destination'], kwargs['remaining'], kwargs['limit']
|
||||||
|
|
||||||
tags = self.get_favorites(ctx, args)
|
tags = self._get_favorites(ctx, args)
|
||||||
|
|
||||||
await dest.trigger_typing()
|
await dest.trigger_typing()
|
||||||
|
|
||||||
posts = await self.check_return_posts(ctx, booru='e926', tags=tags, limit=limit)
|
posts = await self._get_posts(ctx, booru='e926', tags=tags, limit=limit)
|
||||||
|
|
||||||
for ident, post in posts.items():
|
for ident, post in posts.items():
|
||||||
embed = d.Embed(title=post['author'], url='https://e926.net/post/show/{}'.format(ident),
|
embed = d.Embed(title=post['author'], url='https://e926.net/post/show/{}'.format(ident),
|
||||||
|
|
Loading…
Reference in a new issue