OzzyCallooh / DemonButlerBot

The Demon Butler from RuneScape, at your service as a Telegram bot.
1 stars 2 forks source link

Handle downtime of OldSchool RuneScape hiscores gracefully #3

Open OzzyCallooh opened 3 years ago

OzzyCallooh commented 3 years ago

Bot should spit out a descriptive message when hiscores are down (since that happens a lot nowadays...)

ERROR:telegram.ext.dispatcher:An uncaught error was raised while processing the update
Traceback (most recent call last):
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 445, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.6/http/client.py", line 1346, in getresponse
    response.begin()
  File "/usr/lib/python3.6/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.6/http/client.py", line 268, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.6/ssl.py", line 1012, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.6/ssl.py", line 874, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib/python3.6/ssl.py", line 631, in read
    v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 756, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/urllib3/util/retry.py", line 531, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 706, in urlopen
    chunked=chunked,
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 447, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 337, in _raise_timeout
    self, url, "Read timed out. (read timeout=%s)" % timeout_value
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='secure.runescape.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/telegram/ext/dispatcher.py", line 279, in process_update
    handler.handle_update(update, self)
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/telegram/ext/commandhandler.py", line 173, in handle_update
    return self.callback(dispatcher.bot, update, **optional_args)
  File "/usr/local/lib/DemonButlerBot/src/cmdlogging.py", line 16, in wrapped
    return func(bot, update, *args, **kwargs)
  File "/usr/local/lib/DemonButlerBot/src/util.py", line 11, in wrapper
    return func(bot, update, *args, **kwargs)
  File "src/demonbutler.py", line 52, in cmd_stats
    hiscore = osrs.hiscores.HiscoreResult.lookup(player)
  File "/usr/local/lib/DemonButlerBot/src/mwt.py", line 37, in func
    v = self.cache[key] = f(*args,**kwargs),time.time()
  File "/usr/local/lib/DemonButlerBot/src/osrs/hiscores.py", line 108, in lookup
    timeout=5
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/DemonButlerBot/.venv/lib/python3.6/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='secure.runescape.com', port=443): Read timed out. (read timeout=5)