1
0
Fork 0
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:
Myned 2017-10-15 13:31:15 -04:00
commit dd5ffe0c7e
4 changed files with 20 additions and 12 deletions

View file

@ -66,18 +66,22 @@ class MsG:
# Reverse image searches a linked image using the public iqdb # Reverse image searches a linked image using the public iqdb
@commands.command(name='reverse', aliases=['rev', 'ris'], brief='e621 Reverse image search', description='e621 | NSFW\nReverse-search an image with given URL') @commands.command(name='reverse', aliases=['rev', 'ris'], brief='e621 Reverse image search', description='e621 | NSFW\nReverse-search an image with given URL')
@checks.del_ctx() @checks.del_ctx()
async def reverse_image_search(self, ctx, url): async def reverse_image_search(self, ctx, url=None):
try: try:
await ctx.trigger_typing() await ctx.trigger_typing()
if url is None and ctx.message.attachments:
url = ctx.message.attachments[0].url
elif url is None:
raise exc.MissingArgument
await ctx.send('✅ **Probable match:**\n{}'.format(await scraper.check_match(url))) await ctx.send('✅ **Probable match:**\n{}'.format(await scraper.check_match(url)))
except exc.MatchError: except exc.MatchError:
await ctx.send('❌ **No probable match.** Make sure the URL directs to an image file.', delete_after=10) await ctx.send('❌ **No probable match.** Make sure the URL directs to an image file.', delete_after=10)
@reverse_image_search.error except exc.MissingArgument:
async def reverse_image_search_error(self, ctx, error): await ctx.send('❌ **Invalid url or file.**', delete_after=10)
if isinstance(error, errext.MissingRequiredArgument):
return await ctx.send('❌ **Invalid url.**', delete_after=10)
async def return_pool(self, *, ctx, booru='e621', query=[]): async def return_pool(self, *, ctx, booru='e621', query=[]):
def on_message(msg): def on_message(msg):

View file

@ -28,7 +28,7 @@ class Bot:
@checks.del_ctx() @checks.del_ctx()
async def die(self, ctx): async def die(self, ctx):
if isinstance(self.bot.get_channel(u.config['shutdown_channel']), d.TextChannel): if isinstance(self.bot.get_channel(u.config['shutdown_channel']), d.TextChannel):
await self.bot.get_channel(u.config['shutdown_channel']).send('**Shutting down 🌙 . . .**') await self.bot.get_channel(u.config['shutdown_channel']).send('**Shutting down** 🌙 . . .')
# loop = self.bot.loop.all_tasks() # loop = self.bot.loop.all_tasks()
# for task in loop: # for task in loop:
# task.cancel() # task.cancel()
@ -43,7 +43,7 @@ class Bot:
async def restart(self, ctx): async def restart(self, ctx):
print('\n| | | | | | | | | |\nR E S T A R T I N G\n| | | | | | | | | |\n') print('\n| | | | | | | | | |\nR E S T A R T I N G\n| | | | | | | | | |\n')
if isinstance(self.bot.get_channel(u.config['shutdown_channel']), d.TextChannel): if isinstance(self.bot.get_channel(u.config['shutdown_channel']), d.TextChannel):
await self.bot.get_channel(u.config['shutdown_channel']).send('**Restarting 💤 . . .**') await self.bot.get_channel(u.config['shutdown_channel']).send('**Restarting** 💤 . . .')
# u.notify('R E S T A R T I N G') # u.notify('R E S T A R T I N G')
# loop = self.bot.loop.all_tasks() # loop = self.bot.loop.all_tasks()
# for task in loop: # for task in loop:

View file

@ -25,6 +25,10 @@ class Exists(Exception):
pass pass
class MissingArgument(Exception):
pass
class PostError(Exception): class PostError(Exception):
pass pass

View file

@ -35,7 +35,7 @@ async def on_ready():
# bot.loop.create_task(u.clear(booru.temp_urls, 30*60)) # bot.loop.create_task(u.clear(booru.temp_urls, 30*60))
if isinstance(bot.get_channel(u.config['startup_channel']), d.TextChannel): if isinstance(bot.get_channel(u.config['startup_channel']), d.TextChannel):
await bot.get_channel(u.config['startup_channel']).send('**Started ☀️ .**') await bot.get_channel(u.config['startup_channel']).send('**Started** ☀️ .')
print('\n\\ \\ \\ \\ \\ \\ \\ \\ \\\nC O N N E C T E D : {}\n/ / / / / / / / /\n'.format(bot.user.name)) print('\n\\ \\ \\ \\ \\ \\ \\ \\ \\\nC O N N E C T E D : {}\n/ / / / / / / / /\n'.format(bot.user.name))
# u.notify('C O N N E C T E D') # u.notify('C O N N E C T E D')
@ -54,15 +54,15 @@ 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.CheckFailure): if isinstance(error, errext.CheckFailure):
await ctx.send('❌ **Insufficient permissions.**', delete_after=10) await ctx.send('⛔️ **Insufficient permissions.**', delete_after=10)
elif not isinstance(error, errext.CommandNotFound): elif isinstance(error, errext.CommandNotFound):
print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
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 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')
else:
print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
async def on_reaction_add(r, u): async def on_reaction_add(r, u):