From 2adef7c2652dc2a5984058596e2a4aa7875b5dfe Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 25 Oct 2004 08:30:04 +0000 Subject: [PATCH] Make Weather.weather actually work as a wrapped command calling wrapped commands and using the user registry. --- plugins/Weather.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/Weather.py b/plugins/Weather.py index 1bdba9dae..9e7939437 100644 --- a/plugins/Weather.py +++ b/plugins/Weather.py @@ -112,29 +112,30 @@ class Weather(callbacks.Privmsg): channel = None if ircutils.isChannel(msg.args[0]): channel = msg.args[0] - if not args: - s = self.userValue('lastLocation', msg.prefix) - if s: - args = [s] + if not location: + location = self.userValue('lastLocation', msg.prefix) + if location is None: + raise callbacks.ArgumentError self.setUserValue('lastLocation', msg.prefix, location, ignoreNoUser=True) + args = [location] realCommandName = self.registryValue('command', channel) realCommand = getattr(self, realCommandName) try: - realCommand(irc, msg, args) + realCommand(irc, msg, args[:]) except NoLocation: self.log.info('%s lookup failed, Trying others.', realCommandName) for command in self.weatherCommands: if command != realCommandName: self.log.info('Trying %s.', command) try: - getattr(self, command)(irc, msg, args) + getattr(self, command)(irc, msg, args[:]) self.log.info('%s lookup succeeded.', command) break except NoLocation: self.log.info('%s lookup failed as backup.', command) - weather = wrap(weather, ['text']) - + weather = wrap(weather, [additional('text')]) + def _toCelsius(self, temp, unit): if unit == 'K': @@ -304,7 +305,7 @@ class Weather(callbacks.Privmsg): irc.reply(s) else: irc.errorPossibleBug('The format of the page was odd.') - ham = commands.wrap(ham, ['something']) + ham = commands.wrap(ham, ['text']) _cnnUrl = 'http://weather.cnn.com/weather/search?wsearch=' _cnnFTemp = re.compile(r'(-?\d+)(°)(F)', re.I | re.S) @@ -372,7 +373,7 @@ class Weather(callbacks.Privmsg): irc.reply(' '.join(resp)) else: irc.errorPossibleBug('Could not find weather information.') - cnn = commands.wrap(cnn, ['something']) + cnn = commands.wrap(cnn, ['text']) _wunderUrl = 'http://mobile.wunderground.com/cgi-bin/' \ 'findweather/getForecast?query=' @@ -466,7 +467,7 @@ class Weather(callbacks.Privmsg): irc.reply(' '.join(resp)) else: irc.error('Could not find weather information.') - wunder = commands.wrap(wunder, ['something']) + wunder = commands.wrap(wunder, ['text']) conf.registerPlugin('Weather') conf.registerChannelValue(conf.supybot.plugins.Weather, 'temperatureUnit',