1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-25 06:37:29 +00:00

Merge branch 'dev'

This commit is contained in:
Dylan Dizon 2018-11-26 18:54:21 -05:00
commit 3f018dd6e9
3 changed files with 38 additions and 37 deletions

View file

@ -304,7 +304,7 @@ class MsG:
icon_url=self._get_score(post['score'])) icon_url=self._get_score(post['score']))
except exc.MissingArgument: except exc.MissingArgument:
await ctx.send('**Invalid url**') await ctx.send('\N{CROSS MARK} **Invalid url**')
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.message.add_reaction('\N{CROSS MARK}')
@get.command(name='image', aliases=['img'], brief='(get) Get direct image from post', description='Return direct image URL for given post\n\nExample:\n\{p\}get image 1145042') @get.command(name='image', aliases=['img'], brief='(get) Get direct image from post', description='Return direct image URL for given post\n\nExample:\n\{p\}get image 1145042')
@ -331,7 +331,7 @@ class MsG:
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.message.add_reaction('\N{CROSS MARK}')
except exc.MissingArgument: except exc.MissingArgument:
await ctx.send('**Invalid url or file**') await ctx.send('\N{CROSS MARK} **Invalid url or file**')
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.message.add_reaction('\N{CROSS MARK}')
@get.command(name='pool', aliases=['p'], brief='(get) Get pool from query', description='Return pool info for given query\n\nExample:\n\{p\}get pool 1145042') @get.command(name='pool', aliases=['p'], brief='(get) Get pool from query', description='Return pool info for given query\n\nExample:\n\{p\}get pool 1145042')
@ -423,7 +423,7 @@ class MsG:
await ctx.message.delete() await ctx.message.delete()
except exc.MissingArgument: except exc.MissingArgument:
await ctx.send('**Invalid url or file.** Be sure the link directs to an image file') await ctx.send('\N{CROSS MARK} **Invalid url or file.** Be sure the link directs to an image file')
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.message.add_reaction('\N{CROSS MARK}')
except exc.SizeError as e: except exc.SizeError as e:
await ctx.send(f'`{e}` **too large.** Maximum is 8 MB') await ctx.send(f'`{e}` **too large.** Maximum is 8 MB')
@ -1417,7 +1417,7 @@ class MsG:
usage='[blacklist]') usage='[blacklist]')
async def get_blacklist(self, ctx): async def get_blacklist(self, ctx):
if not ctx.invoked_subcommand: if not ctx.invoked_subcommand:
await ctx.send('**Invalid blacklist**') await ctx.send('\N{CROSS MARK} **Invalid blacklist**')
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.message.add_reaction('\N{CROSS MARK}')
@get_blacklist.command( @get_blacklist.command(
@ -1483,7 +1483,7 @@ class MsG:
usage='[blacklist] [tags...]') usage='[blacklist] [tags...]')
async def add_tags(self, ctx): async def add_tags(self, ctx):
if not ctx.invoked_subcommand: if not ctx.invoked_subcommand:
await ctx.send('**Invalid blacklist**') await ctx.send('\N{CROSS MARK} **Invalid blacklist**')
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.message.add_reaction('\N{CROSS MARK}')
async def _add(self, tags, lst, alias=False): async def _add(self, tags, lst, alias=False):
@ -1586,7 +1586,7 @@ class MsG:
usage='[blacklist] [tags...]') usage='[blacklist] [tags...]')
async def remove_tags(self, ctx): async def remove_tags(self, ctx):
if not ctx.invoked_subcommand: if not ctx.invoked_subcommand:
await ctx.send('**Invalid blacklist**') await ctx.send('\N{CROSS MARK} **Invalid blacklist**')
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.message.add_reaction('\N{CROSS MARK}')
def _remove(self, remove, lst): def _remove(self, remove, lst):
@ -1684,7 +1684,7 @@ class MsG:
usage='[blacklist]') usage='[blacklist]')
async def clear_blacklist(self, ctx): async def clear_blacklist(self, ctx):
if not ctx.invoked_subcommand: if not ctx.invoked_subcommand:
await ctx.send('**Invalid blacklist**') await ctx.send('\N{CROSS MARK} **Invalid blacklist**')
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.message.add_reaction('\N{CROSS MARK}')
@clear_blacklist.command( @clear_blacklist.command(

View file

@ -159,35 +159,36 @@ async def on_error(error, *args, **kwargs):
@bot.event @bot.event
async def on_command_error(ctx, error): async def on_command_error(ctx, error):
if isinstance(error, errext.CommandOnCooldown): with suppress(err.NotFound):
await ctx.message.add_reaction('\N{HOURGLASS}') if isinstance(error, errext.CommandOnCooldown):
await asyncio.sleep(error.retry_after) await ctx.message.add_reaction('\N{HOURGLASS}')
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}') await asyncio.sleep(error.retry_after)
elif isinstance(error, err.NotFound): await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
print('NOT FOUND') elif isinstance(error, err.NotFound):
elif isinstance(error, err.Forbidden): print('NOT FOUND')
pass elif isinstance(error, err.Forbidden):
elif isinstance(error, errext.MissingRequiredArgument): pass
await ctx.send('**Missing required argument**') elif isinstance(error, errext.MissingRequiredArgument):
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.send('**Missing required argument**')
elif isinstance(error, errext.BadArgument): await ctx.message.add_reaction('\N{CROSS MARK}')
await ctx.send(f'**Invalid argument.** {error}') elif isinstance(error, errext.BadArgument):
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.send(f'**Invalid argument.** {error}')
elif isinstance(error, errext.CheckFailure): await ctx.message.add_reaction('\N{CROSS MARK}')
await ctx.send('**Insufficient permissions**') elif isinstance(error, errext.CheckFailure):
await ctx.message.add_reaction('\N{NO ENTRY}') await ctx.send('**Insufficient permissions**')
elif isinstance(error, errext.CommandNotFound): await ctx.message.add_reaction('\N{NO ENTRY}')
print('INVALID COMMAND : {}'.format(error), file=sys.stderr) elif isinstance(error, errext.CommandNotFound):
await ctx.message.add_reaction('\N{BLACK QUESTION MARK ORNAMENT}') print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
else: await ctx.message.add_reaction('\N{BLACK QUESTION MARK ORNAMENT}')
print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format( else:
error), file=sys.stderr) print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format(
tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr) error), file=sys.stderr)
await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error)) tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.name, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error)) await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error))
await exc.send_error(ctx, error) await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.name, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error))
await ctx.message.add_reaction('\N{WARNING SIGN}') await exc.send_error(ctx, error)
# u.notify('C O M M A N D E R R O R') await ctx.message.add_reaction('\N{WARNING SIGN}')
# u.notify('C O M M A N D E R R O R')
# @bot.event # @bot.event
# async def on_command(ctx): # async def on_command(ctx):

View file

@ -16,7 +16,7 @@ async def get_post(url):
if filesize > 8192 * 1024: if filesize > 8192 * 1024:
raise exc.SizeError(size(filesize, system=alternative)) raise exc.SizeError(size(filesize, system=alternative))
except ValueError: except (ValueError, KeyError):
raise exc.MissingArgument raise exc.MissingArgument
content = await u.fetch('http://iqdb.harry.lu', params={'url': url}) content = await u.fetch('http://iqdb.harry.lu', params={'url': url})