if a nickname has no location set, assume it's a location
This commit is contained in:
parent
480a4f73a9
commit
f7d34e16bb
1 changed files with 11 additions and 9 deletions
|
@ -16,27 +16,29 @@ class Module(ModuleManager.BaseModule):
|
||||||
_name = "Time"
|
_name = "Time"
|
||||||
|
|
||||||
def _find_setting(self, event):
|
def _find_setting(self, event):
|
||||||
target_user = event["user"]
|
query = 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])
|
||||||
else:
|
else:
|
||||||
location = self.exports.get_one("get-location")(event["args"])
|
target_user = event["user"]
|
||||||
if location:
|
|
||||||
return (LocationType.NAME, location["name"],
|
|
||||||
location["timezone"])
|
|
||||||
else:
|
|
||||||
return LocationType.NAME, event["args"], None
|
|
||||||
|
|
||||||
if target_user:
|
if target_user:
|
||||||
location = target_user.get_setting("location", None)
|
location = target_user.get_setting("location", None)
|
||||||
if location:
|
if location:
|
||||||
return (LocationType.USER, target_user.nickname,
|
return (LocationType.USER, target_user.nickname,
|
||||||
location["timezone"])
|
location["timezone"])
|
||||||
|
|
||||||
|
if query:
|
||||||
|
location = self.exports.get_one("get-location")(query)
|
||||||
|
if location:
|
||||||
|
return (LocationType.NAME, location["name"],
|
||||||
|
location["timezone"])
|
||||||
else:
|
else:
|
||||||
return LocationType.USER, target_user.nickname, None
|
return LocationType.NAME, event["args"], None
|
||||||
|
|
||||||
|
|
||||||
@utils.hook("received.command.time")
|
@utils.hook("received.command.time")
|
||||||
|
|
Loading…
Reference in a new issue