From d0c72bc290077bef23488dd88f69058c6c3fd073 Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 1 Nov 2019 19:18:25 -0400 Subject: [PATCH 1/2] Fix SauceNAO returning server errors for some images --- src/utils/scraper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/scraper.py b/src/utils/scraper.py index 8680d31..35ff235 100644 --- a/src/utils/scraper.py +++ b/src/utils/scraper.py @@ -83,7 +83,9 @@ async def query_saucenao(url): params={'url': url, 'api_key': u.config['saucenao_api'], 'output_type': 2}, json=True) - if content['header'].get('message', '') == 'Access to specified file was denied... ;_;': + if content['header'].get('message', '') in ( + 'Access to specified file was denied... ;_;', + 'Problem with remote server...'): raise exc.ImageError match = content['results'][0] From dd832f44866e1c71c2ee6f386abfd65477b6a4fe Mon Sep 17 00:00:00 2001 From: Myned Date: Fri, 1 Nov 2019 19:19:09 -0400 Subject: [PATCH 2/2] Change formatting and semantics for command error responses --- src/cogs/booru.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cogs/booru.py b/src/cogs/booru.py index aa46724..0fa1096 100644 --- a/src/cogs/booru.py +++ b/src/cogs/booru.py @@ -422,18 +422,22 @@ class MsG(cmds.Cog): await ctx.message.delete() except exc.MissingArgument: - await ctx.send('\N{HEAVY EXCLAMATION MARK SYMBOL} **Invalid url or file.** Be sure the link directs to an image file') + await ctx.send( + '\N{HEAVY EXCLAMATION MARK SYMBOL} **Invalid url or file.**\n' + 'Be sure the link directs to an image file') await u.add_reaction(ctx.message, '\N{HEAVY EXCLAMATION MARK SYMBOL}') except exc.SizeError as e: - await ctx.send(f'`{e}` **too large.** Maximum is 8 MB') + await ctx.send(f'`{e}` **too large.**\nMaximum is 8 MB') await u.add_reaction(ctx.message, '\N{HEAVY EXCLAMATION MARK SYMBOL}') except err.HTTPException: - await ctx.send('\N{HEAVY EXCLAMATION MARK SYMBOL} **The image database returned an unexpected result.** It may be offline') + await ctx.send( + '\N{HEAVY EXCLAMATION MARK SYMBOL} **Search engines returned an unexpected result.**\n' + 'They may be offline') await u.add_reaction(ctx.message, '\N{HEAVY EXCLAMATION MARK SYMBOL}') except exc.ImageError: await ctx.send( - '\N{HEAVY EXCLAMATION MARK SYMBOL} **None of the search engines could use this file.** ' - 'Try opening it in a browser and uploading the copied file into Discord') + '\N{HEAVY EXCLAMATION MARK SYMBOL} **Search engines were denied access to this file.**\n' + 'Try opening it in a browser and uploading the file to Discord') @cmds.command(name='reversify', aliases=['revify', 'risify', 'rify']) @cmds.cooldown(1, 5, cmds.BucketType.member) @@ -494,7 +498,7 @@ class MsG(cmds.Cog): await message.add_reaction('\N{CROSS MARK}') c -= 1 except exc.SizeError as e: - await dest.send(f'`{e}` **too large.** Maximum is 8 MB') + await dest.send(f'`{e}` **too large.**\nMaximum is 8 MB') await message.add_reaction('\N{CROSS MARK}') c -= 1 @@ -508,15 +512,17 @@ class MsG(cmds.Cog): await dest.send('**No matches found**') await u.add_reaction(ctx.message, '\N{HEAVY EXCLAMATION MARK SYMBOL}') except exc.BoundsError as e: - await dest.send('`{}` **invalid limit.** Query limited to 5'.format(e)) + await dest.send('`{}` **invalid limit.**\nQuery limited to 5'.format(e)) await u.add_reaction(ctx.message, '\N{HEAVY EXCLAMATION MARK SYMBOL}') except err.HTTPException: - await dest.send('\N{HEAVY EXCLAMATION MARK SYMBOL} **The image database returned an unexpected result.** It may be offline') + await dest.send( + '\N{HEAVY EXCLAMATION MARK SYMBOL} **Search engines returned an unexpected result.**\n' + 'They may be offline') await u.add_reaction(ctx.message, '\N{HEAVY EXCLAMATION MARK SYMBOL}') except exc.ImageError: await ctx.send( - '\N{HEAVY EXCLAMATION MARK SYMBOL} **None of the search engines could use this file.** ' - 'Try opening it in a browser and uploading the copied file into Discord') + '\N{HEAVY EXCLAMATION MARK SYMBOL} **Search engines were denied access to this file.**\n' + 'Try opening it in a browser and uploading the file to Discord') async def _reversify(self): while self.reversifying: