dont fail !weather when we decide a nickname is a location
This commit is contained in:
parent
6d29291f47
commit
4a4a0ac45b
1 changed files with 9 additions and 8 deletions
|
@ -25,15 +25,15 @@ class Module(ModuleManager.BaseModule):
|
||||||
api_key = self.bot.config["openweathermap-api-key"]
|
api_key = self.bot.config["openweathermap-api-key"]
|
||||||
|
|
||||||
location = None
|
location = None
|
||||||
|
query = None
|
||||||
nickname = None
|
nickname = None
|
||||||
if event["args"]:
|
if event["args"]:
|
||||||
|
query = event["args"]
|
||||||
if len(event["args_split"]) == 1 and event["server"].has_user_id(
|
if len(event["args_split"]) == 1 and event["server"].has_user_id(
|
||||||
event["args_split"][0]):
|
event["args_split"][0]):
|
||||||
target_user = event["server"].get_user(event["args_split"][0])
|
target_user = event["server"].get_user(event["args_split"][0])
|
||||||
location = self._user_location(target_user)
|
location = self._user_location(target_user)
|
||||||
if location == None:
|
if not location == None:
|
||||||
location = event["args_split"][0]
|
|
||||||
else:
|
|
||||||
nickname = target_user.nickname
|
nickname = target_user.nickname
|
||||||
else:
|
else:
|
||||||
location = self._user_location(event["user"])
|
location = self._user_location(event["user"])
|
||||||
|
@ -44,12 +44,13 @@ class Module(ModuleManager.BaseModule):
|
||||||
args = {"units": "metric", "APPID": api_key}
|
args = {"units": "metric", "APPID": api_key}
|
||||||
|
|
||||||
|
|
||||||
if location == None:
|
if location == None and query:
|
||||||
location_info = self.exports.get_one("get-location")(event["args"])
|
location_info = self.exports.get_one("get-location")(query)
|
||||||
if location_info == None:
|
if not location_info == None:
|
||||||
raise utils.EventError("Unknown location")
|
|
||||||
location = [location_info["lat"], location_info["lon"],
|
location = [location_info["lat"], location_info["lon"],
|
||||||
location_info.get("name", None)]
|
location_info.get("name", None)]
|
||||||
|
if location == None:
|
||||||
|
raise utils.EventError("Unknown location")
|
||||||
|
|
||||||
lat, lon, location_name = location
|
lat, lon, location_name = location
|
||||||
args["lat"] = lat
|
args["lat"] = lat
|
||||||
|
|
Loading…
Reference in a new issue