From 4b43b4ea6acc06f58a6d6870c44b061d9d3534f0 Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 1 Oct 2019 21:57:58 -0400 Subject: [PATCH 1/4] Remove vestigial code --- src/misc/exceptions.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/misc/exceptions.py b/src/misc/exceptions.py index ac58f01..4c94ed2 100644 --- a/src/misc/exceptions.py +++ b/src/misc/exceptions.py @@ -7,12 +7,10 @@ async def send_error(ctx, error): await ctx.send('{}\n```\n{}```'.format(base, error)) -# class NSFW(errext.CheckFailure): -# pass - class Remove(Exception): pass + class SizeError(Exception): pass @@ -46,6 +44,7 @@ class Save(Exception): self.user = user self.message = message + class GoTo(Exception): pass From 65329b81d46595ada92ca8f7c331c5e894cdad72 Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 1 Oct 2019 21:58:32 -0400 Subject: [PATCH 2/4] Change wording to align with existing terms --- src/utils/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.py b/src/utils/utils.py index 6298cb2..ca569a3 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -24,7 +24,7 @@ except FileNotFoundError: with open('config.json', 'w') as outfile: jsn.dump({'client_id': 0, 'owner_id': 0, 'permissions': 126016, 'playing': 'a game', 'prefix': [',', 'm,'], 'selfbot': False, 'token': 'str', 'saucenao_api': 'str'}, outfile, indent=4, sort_keys=True) - print('FILE NOT FOUND : config.json created with abstract values. Restart run.py with correct values') + print('FILE NOT FOUND : config.json created with default values. Restart run.py with correct values') def setdefault(filename, default=None, json=False): From 78c78c61d1ab1ffb0964cba2f157c126693a076a Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 1 Oct 2019 21:59:00 -0400 Subject: [PATCH 3/4] Change fetch logic to be more logical --- src/utils/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/utils.py b/src/utils/utils.py index ca569a3..c7f9fe2 100644 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -87,10 +87,10 @@ asession = aiohttp.ClientSession() async def fetch(url, *, params={}, json=False, response=False, text=False): async with asession.get(url, params=params, headers={ 'User-Agent': 'Myned/Modufur (https://github.com/Myned/Modufur)'}, ssl=False) as r: - if json: - return await r.json() - elif response: + if response: return r + elif json: + return await r.json() elif text: return await r.text() else: From 82e010c7957843aa45b2a89bfbba6e472ce9c655 Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 1 Oct 2019 21:59:32 -0400 Subject: [PATCH 4/4] Fix Kheina returning content-type errors --- src/utils/scraper.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/scraper.py b/src/utils/scraper.py index 49edfc5..d7817db 100644 --- a/src/utils/scraper.py +++ b/src/utils/scraper.py @@ -48,6 +48,10 @@ async def query_kheina(url): content = re.sub('', '', content) soup = BeautifulSoup(content, 'html5lib') + + if soup.find('data', id='error'): + return False + results = soup.find('data', id='results').string results = ast.literal_eval(results) iqdbdata = soup.find('data', id='iqdbdata').string