telegram-bots / imaginaryfriend

:rocket: Telegram bot
46 stars 18 forks source link

Cat API returns 403 Forbidden #58

Closed eugenweissbart closed 4 years ago

eugenweissbart commented 5 years ago

Version: master (commit ac75bab) Action: sending /meow to the bot Expected behaviour: receiving cat photo in response Actual behaviour:


bot_1    | Traceback (most recent call last):
bot_1    |   File "/usr/local/lib/python3.6/site-packages/telegram/utils/promise.py", line 42, in run
bot_1    |     self._result = self.pooled_function(*self.args, **self.kwargs)
bot_1    |   File "/code/src/handler/command_handler.py", line 39, in handle
bot_1    |     command.execute(data)
bot_1    |   File "/code/src/handler/commands/meow.py", line 11, in execute
bot_1    |     req = opener.open('http://thecatapi.com/api/images/get?format=src')
bot_1    |   File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
bot_1    |     response = meth(req, response)
bot_1    |   File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
bot_1    |     'http', request, response, code, msg, hdrs)
bot_1    |   File "/usr/local/lib/python3.6/urllib/request.py", line 570, in error
bot_1    |     return self._call_chain(*args)
bot_1    |   File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
bot_1    |     result = func(*args)
bot_1    |   File "/usr/local/lib/python3.6/urllib/request.py", line 650, in http_error_default
bot_1    |     raise HTTPError(req.full_url, code, msg, hdrs, fp)
bot_1    | urllib.error.HTTPError: HTTP Error 403: Forbidden```
eugenweissbart commented 5 years ago

https://api.thecatapi.com/v1/images/search seems to work, will refactor the code to use it