From b443202030f614875a18e082d752c9bb7674e25f Mon Sep 17 00:00:00 2001 From: Anton McClure Date: Wed, 3 Jul 2019 12:03:48 +0000 Subject: [PATCH] Add user nickname to \!weather prefix --- modules/weather.py | 6 ++++++ 1 file changed, 6 insertions(+) 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,