Jintaku / Jintaku-Cogs-V3

V3 Cogs made by the Jintaku community
GNU Affero General Public License v3.0
39 stars 40 forks source link

[wikia] setting default domain should have a check to see that it is a URL and not a name #17

Open kennnyshiwa opened 5 years ago

kennnyshiwa commented 5 years ago

Attempted to use wikiaset to set starwars as the default domain. Then attempted to search for something in this case han solo and broke the cog


Traceback (most recent call last):
  File "/home/kstjohn_kstj_us/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/kstjohn_kstj_us/.local/share/Red-DiscordBot/cogs/CogManager/cogs/wikia/wikia.py", line 26, in wikia
    await self.search_article(ctx, query, domain)
  File "/home/kstjohn_kstj_us/.local/share/Red-DiscordBot/cogs/CogManager/cogs/wikia/wikia.py", line 116, in search_article
    async with session.post(str(domain) + "/api/v1/Search/List?limit=10&batch=1&query=" + article, headers=headers) as response:
  File "/home/kstjohn_kstj_us/venv/lib/python3.7/site-packages/aiohttp/client.py", line 1005, in __aenter__
    self._resp = await self._coro
  File "/home/kstjohn_kstj_us/venv/lib/python3.7/site-packages/aiohttp/client.py", line 466, in _request
    ssl=ssl, proxy_headers=proxy_headers, traces=traces)
  File "/home/kstjohn_kstj_us/venv/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 286, in __init__
    self.update_host(url)
  File "/home/kstjohn_kstj_us/venv/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 340, in update_host
    raise InvalidURL(url)
aiohttp.client_exceptions.InvalidURL: starwars/api/v1/Search/List?limit=10&batch=1&query=Han+Solo

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/kstjohn_kstj_us/venv/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 863, in invoke
    await ctx.command.invoke(ctx)
  File "/home/kstjohn_kstj_us/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 728, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/kstjohn_kstj_us/venv/lib/python3.7/site-packages/discord/ext/commands/core.py", line 88, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: InvalidURL: starwars/api/v1/Search/List?limit=10&batch=1&query=Han+Solo```
kennnyshiwa commented 5 years ago

Nevermind, didn't see that the default wikia site needed to be the url not the name, sorry

lionirdeadman commented 5 years ago

I should probably make something as to avoid this problem so I'll reopen this issue and rename it