aboutsummaryrefslogtreecommitdiff
path: root/modules/weather.py
diff options
context:
space:
mode:
authorGravatar Anton McClure2019-07-03 12:03:48 +0000
committerGravatar Anton McClure2019-07-03 12:03:48 +0000
commitb443202030f614875a18e082d752c9bb7674e25f (patch)
tree944bd7b17b1c0f705a1ad51c3939e7830ba6c18f /modules/weather.py
parent< is important! (diff)
Add user nickname to \!weather prefix
Diffstat (limited to 'modules/weather.py')
-rw-r--r--modules/weather.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/weather.py b/modules/weather.py
index 1bbd127d..4314f0f3 100644
--- a/modules/weather.py
+++ b/modules/weather.py
@@ -25,6 +25,7 @@ class Module(ModuleManager.BaseModule):
api_key = self.bot.config["openweathermap-api-key"]
location = None
+ nickname = None
if event["args"]:
if len(event["args_split"]) == 1 and event["server"].has_user_id(
event["args_split"][0]):
@@ -33,8 +34,11 @@ class Module(ModuleManager.BaseModule):
if location == None:
raise utils.EventError("%s doesn't have a location set"
% target_user.nickname)
+ else:
+ nickname = target_user.nickname
else:
location = self._user_location(event["user"])
+ nickname = event["user"].nickname
if location == None:
raise utils.EventError("You don't have a location set")
@@ -69,6 +73,8 @@ class Module(ModuleManager.BaseModule):
wind_speed_k = "%sKMh" % round(wind_speed, 1)
wind_speed_m = "%sMPh" % round(0.6214*wind_speed, 1)
+ if not nickname == None:
+ event["stdout"].set_prefix("Weather|%s" % nickname)
event["stdout"].write(
"(%s) %s/%s | %s | Humidity: %s | Wind: %s/%s" % (
location_str, celsius, fahrenheit, description, humidity,