mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01:00
Make Weather.weather actually work as a wrapped command calling wrapped
commands and using the user registry.
This commit is contained in:
parent
de711b5bab
commit
2adef7c265
@ -112,29 +112,30 @@ class Weather(callbacks.Privmsg):
|
|||||||
channel = None
|
channel = None
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if not args:
|
if not location:
|
||||||
s = self.userValue('lastLocation', msg.prefix)
|
location = self.userValue('lastLocation', msg.prefix)
|
||||||
if s:
|
if location is None:
|
||||||
args = [s]
|
raise callbacks.ArgumentError
|
||||||
self.setUserValue('lastLocation', msg.prefix,
|
self.setUserValue('lastLocation', msg.prefix,
|
||||||
location, ignoreNoUser=True)
|
location, ignoreNoUser=True)
|
||||||
|
args = [location]
|
||||||
realCommandName = self.registryValue('command', channel)
|
realCommandName = self.registryValue('command', channel)
|
||||||
realCommand = getattr(self, realCommandName)
|
realCommand = getattr(self, realCommandName)
|
||||||
try:
|
try:
|
||||||
realCommand(irc, msg, args)
|
realCommand(irc, msg, args[:])
|
||||||
except NoLocation:
|
except NoLocation:
|
||||||
self.log.info('%s lookup failed, Trying others.', realCommandName)
|
self.log.info('%s lookup failed, Trying others.', realCommandName)
|
||||||
for command in self.weatherCommands:
|
for command in self.weatherCommands:
|
||||||
if command != realCommandName:
|
if command != realCommandName:
|
||||||
self.log.info('Trying %s.', command)
|
self.log.info('Trying %s.', command)
|
||||||
try:
|
try:
|
||||||
getattr(self, command)(irc, msg, args)
|
getattr(self, command)(irc, msg, args[:])
|
||||||
self.log.info('%s lookup succeeded.', command)
|
self.log.info('%s lookup succeeded.', command)
|
||||||
break
|
break
|
||||||
except NoLocation:
|
except NoLocation:
|
||||||
self.log.info('%s lookup failed as backup.', command)
|
self.log.info('%s lookup failed as backup.', command)
|
||||||
weather = wrap(weather, ['text'])
|
weather = wrap(weather, [additional('text')])
|
||||||
|
|
||||||
|
|
||||||
def _toCelsius(self, temp, unit):
|
def _toCelsius(self, temp, unit):
|
||||||
if unit == 'K':
|
if unit == 'K':
|
||||||
@ -304,7 +305,7 @@ class Weather(callbacks.Privmsg):
|
|||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
else:
|
else:
|
||||||
irc.errorPossibleBug('The format of the page was odd.')
|
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='
|
_cnnUrl = 'http://weather.cnn.com/weather/search?wsearch='
|
||||||
_cnnFTemp = re.compile(r'(-?\d+)(°)(F)</span>', re.I | re.S)
|
_cnnFTemp = re.compile(r'(-?\d+)(°)(F)</span>', re.I | re.S)
|
||||||
@ -372,7 +373,7 @@ class Weather(callbacks.Privmsg):
|
|||||||
irc.reply(' '.join(resp))
|
irc.reply(' '.join(resp))
|
||||||
else:
|
else:
|
||||||
irc.errorPossibleBug('Could not find weather information.')
|
irc.errorPossibleBug('Could not find weather information.')
|
||||||
cnn = commands.wrap(cnn, ['something'])
|
cnn = commands.wrap(cnn, ['text'])
|
||||||
|
|
||||||
_wunderUrl = 'http://mobile.wunderground.com/cgi-bin/' \
|
_wunderUrl = 'http://mobile.wunderground.com/cgi-bin/' \
|
||||||
'findweather/getForecast?query='
|
'findweather/getForecast?query='
|
||||||
@ -466,7 +467,7 @@ class Weather(callbacks.Privmsg):
|
|||||||
irc.reply(' '.join(resp))
|
irc.reply(' '.join(resp))
|
||||||
else:
|
else:
|
||||||
irc.error('Could not find weather information.')
|
irc.error('Could not find weather information.')
|
||||||
wunder = commands.wrap(wunder, ['something'])
|
wunder = commands.wrap(wunder, ['text'])
|
||||||
|
|
||||||
conf.registerPlugin('Weather')
|
conf.registerPlugin('Weather')
|
||||||
conf.registerChannelValue(conf.supybot.plugins.Weather, 'temperatureUnit',
|
conf.registerChannelValue(conf.supybot.plugins.Weather, 'temperatureUnit',
|
||||||
|
Loading…
Reference in New Issue
Block a user