mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 22:27:28 +00:00
Merge branch 'dev'
This commit is contained in:
commit
ca8bd8eb18
3 changed files with 19 additions and 14 deletions
|
@ -21,6 +21,7 @@ class MsG:
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
self.color = d.Color(0x1A1A1A)
|
||||||
self.LIMIT = 100
|
self.LIMIT = 100
|
||||||
self.RATE_LIMIT = u.RATE_LIMIT
|
self.RATE_LIMIT = u.RATE_LIMIT
|
||||||
self.queue = asyncio.Queue()
|
self.queue = asyncio.Queue()
|
||||||
|
@ -498,7 +499,7 @@ class MsG:
|
||||||
values = list(posts.values())
|
values = list(posts.values())
|
||||||
|
|
||||||
embed = d.Embed(
|
embed = d.Embed(
|
||||||
title=values[c - 1]['author'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=ctx.me.color).set_image(url=values[c - 1]['url'])
|
title=values[c - 1]['author'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else self.color).set_image(url=values[c - 1]['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)),
|
||||||
|
@ -618,9 +619,9 @@ class MsG:
|
||||||
posts = {}
|
posts = {}
|
||||||
c = 0
|
c = 0
|
||||||
while len(posts) < limit:
|
while len(posts) < limit:
|
||||||
if c == 50 + limit * 3:
|
if c == limit * 5 + self.LIMIT:
|
||||||
raise exc.Timeout
|
raise exc.Timeout
|
||||||
request = await u.fetch('https://{}.net/post/index.json'.format(booru), params={'tags': ','.join(['order:random'] + tags), 'limit': self.LIMIT}, json=True)
|
request = await u.fetch('https://{}.net/post/index.json'.format(booru), params={'tags': ','.join(['order:random'] + tags), 'limit': self.LIMIT * limit}, json=True)
|
||||||
if len(request) == 0:
|
if len(request) == 0:
|
||||||
raise exc.NotFound(formatter.tostring(tags))
|
raise exc.NotFound(formatter.tostring(tags))
|
||||||
if len(request) < limit:
|
if len(request) < limit:
|
||||||
|
@ -681,7 +682,7 @@ class MsG:
|
||||||
values = list(posts.values())
|
values = list(posts.values())
|
||||||
|
|
||||||
embed = d.Embed(
|
embed = d.Embed(
|
||||||
title=values[c - 1]['author'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=ctx.me.color).set_image(url=values[c - 1]['url'])
|
title=values[c - 1]['author'], url='https://e621.net/post/show/{}'.format(keys[c - 1]), color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else self.color).set_image(url=values[c - 1]['url'])
|
||||||
embed.set_author(name=formatter.tostring(args, random=True),
|
embed.set_author(name=formatter.tostring(args, random=True),
|
||||||
url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=ctx.author.avatar_url)
|
url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=ctx.author.avatar_url)
|
||||||
embed.set_footer(text='{} / {}'.format(c, len(posts)),
|
embed.set_footer(text='{} / {}'.format(c, len(posts)),
|
||||||
|
@ -797,7 +798,7 @@ class MsG:
|
||||||
async def e621_paginator_error(self, ctx, error):
|
async def e621_paginator_error(self, ctx, error):
|
||||||
if isinstance(error, errext.CheckFailure):
|
if isinstance(error, errext.CheckFailure):
|
||||||
await ctx.send('⛔️ {} **is not an NSFW channel.**'.format(ctx.channel.mention), delete_after=10)
|
await ctx.send('⛔️ {} **is not an NSFW channel.**'.format(ctx.channel.mention), delete_after=10)
|
||||||
return await ctx.message.add_reaction('❌')
|
return await ctx.message.add_reaction('⛔️')
|
||||||
|
|
||||||
def get_limit(self, args):
|
def get_limit(self, args):
|
||||||
limit = 1
|
limit = 1
|
||||||
|
@ -831,7 +832,7 @@ class MsG:
|
||||||
|
|
||||||
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),
|
||||||
color=ctx.me.color).set_image(url=post['url'])
|
color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else self.color).set_image(url=post['url'])
|
||||||
embed.set_author(name=formatter.tostring(args, random=True),
|
embed.set_author(name=formatter.tostring(args, random=True),
|
||||||
url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=ctx.author.avatar_url)
|
url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=ctx.author.avatar_url)
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
|
@ -866,7 +867,8 @@ class MsG:
|
||||||
@e621.error
|
@e621.error
|
||||||
async def e621_error(self, ctx, error):
|
async def e621_error(self, ctx, error):
|
||||||
if isinstance(error, errext.CheckFailure):
|
if isinstance(error, errext.CheckFailure):
|
||||||
return await ctx.send('⛔️ {} **is not an NSFW channel.**'.format(ctx.channel.mention), delete_after=10)
|
await ctx.send('⛔️ {} **is not an NSFW channel.**'.format(ctx.channel.mention), delete_after=10)
|
||||||
|
return await ctx.message.add_reaction('⛔️')
|
||||||
|
|
||||||
# Searches for and returns images from e926.net given tags when not blacklisted
|
# Searches for and returns images from e926.net given tags when not blacklisted
|
||||||
@commands.command(aliases=['e9', '9'], brief='e926 | SFW', description='e926 | SFW\nTag-based search for e926.net\n\nYou can only search 5 tags and 6 images at once for now.\ne9 [tags...] ([# of images])')
|
@commands.command(aliases=['e9', '9'], brief='e926 | SFW', description='e926 | SFW\nTag-based search for e926.net\n\nYou can only search 5 tags and 6 images at once for now.\ne9 [tags...] ([# of images])')
|
||||||
|
@ -884,7 +886,7 @@ class MsG:
|
||||||
|
|
||||||
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),
|
||||||
color=ctx.me.color).set_image(url=post['url'])
|
color=ctx.me.color if isinstance(ctx.channel, d.TextChannel) else self.color).set_image(url=post['url'])
|
||||||
embed.set_author(name=formatter.tostring(args, random=True),
|
embed.set_author(name=formatter.tostring(args, random=True),
|
||||||
url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=ctx.author.avatar_url)
|
url='https://e621.net/post?tags={}'.format(','.join(args)), icon_url=ctx.author.avatar_url)
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
|
|
|
@ -53,8 +53,9 @@ def is_nsfw():
|
||||||
|
|
||||||
def del_ctx():
|
def del_ctx():
|
||||||
async def predicate(ctx):
|
async def predicate(ctx):
|
||||||
if ctx.guild.id in u.settings['del_ctx'] and ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, d.TextChannel):
|
with suppress(AttributeError):
|
||||||
with suppress(err.NotFound):
|
if ctx.guild.id in u.settings['del_ctx'] and ctx.me.permissions_in(ctx.channel).manage_messages and isinstance(ctx.message.channel, d.TextChannel):
|
||||||
await ctx.message.delete()
|
with suppress(err.NotFound):
|
||||||
|
await ctx.message.delete()
|
||||||
return True
|
return True
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
|
@ -54,7 +54,8 @@ async def on_ready():
|
||||||
async def on_error(error, *args, **kwargs):
|
async def on_error(error, *args, **kwargs):
|
||||||
print('\n! ! ! ! !\nE R R O R : {}\n! ! ! ! !\n'.format(error), file=sys.stderr)
|
print('\n! ! ! ! !\nE R R O R : {}\n! ! ! ! !\n'.format(error), file=sys.stderr)
|
||||||
tb.print_exc()
|
tb.print_exc()
|
||||||
await bot.get_channel(u.config['info_channel']).send('**ERROR** ⚠️ {}'.format(error))
|
await bot.get_user(u.config['owner_id']).send('**ERROR** ⚠️ `{}`'.format(error))
|
||||||
|
await bot.get_channel(u.config['info_channel']).send('**ERROR** ⚠️ `{}`'.format(error))
|
||||||
# u.notify('E R R O R')
|
# u.notify('E R R O R')
|
||||||
await bot.logout()
|
await bot.logout()
|
||||||
u.close(bot.loop)
|
u.close(bot.loop)
|
||||||
|
@ -64,14 +65,15 @@ async def on_error(error, *args, **kwargs):
|
||||||
async def on_command_error(ctx, error):
|
async def on_command_error(ctx, error):
|
||||||
if isinstance(error, errext.CheckFailure):
|
if isinstance(error, errext.CheckFailure):
|
||||||
await ctx.send('⛔️ **Insufficient permissions.**', delete_after=10)
|
await ctx.send('⛔️ **Insufficient permissions.**', delete_after=10)
|
||||||
|
await ctx.message.add_reaction('⛔️')
|
||||||
elif isinstance(error, errext.CommandNotFound):
|
elif isinstance(error, errext.CommandNotFound):
|
||||||
print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
|
print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format(
|
print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format(
|
||||||
error), file=sys.stderr)
|
error), file=sys.stderr)
|
||||||
tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
|
tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
|
||||||
await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** ⚠️ {}'.format(error))
|
await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** ⚠️ `{}`'.format(error))
|
||||||
await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** ⚠️ {}'.format(error))
|
await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** ⚠️ `{}`'.format(error))
|
||||||
await exc.send_error(ctx, error)
|
await exc.send_error(ctx, error)
|
||||||
# u.notify('C O M M A N D E R R O R')
|
# u.notify('C O M M A N D E R R O R')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue