Gracefully handle a timeout (wolframalpha)

This commit is contained in:
jesopo 2019-01-20 19:04:32 +00:00
parent 491db4fea4
commit 65f9184a54

View file

@ -14,10 +14,13 @@ class Module(ModuleManager.BaseModule):
:help: Evauate a given string on Wolfram|Alpha
:usage: <query>
"""
page = utils.http.request(URL_WA,
get_params={"i": event["args"],
"appid": self.bot.config["wolframalpha-api-key"],
"reinterpret": "true", "units": "metric"}, code=True)
try:
page = utils.http.request(URL_WA,
get_params={"i": event["args"],
"appid": self.bot.config["wolframalpha-api-key"],
"reinterpret": "true", "units": "metric"}, code=True)
except HTTPTimeoutException:
page = None
if page:
if page.code == 200: