Make !find and !info more robust

Add a new configuration variable 'tzUrl' for the location of a list of supported timezones
Remove silly code that said "GMT" is not a valid timezone
This commit is contained in:
Terence Simpson 2008-05-06 17:22:00 +01:00
parent c2be01c5c0
commit 9fa81121c8
3 changed files with 9 additions and 4 deletions

View File

@ -88,6 +88,9 @@ class Apt:
parser = FeedParser.FeedParser()
parser.feed(p)
p = parser.close()
if type(p) == type(""):
plugin.log.error("apt returned an error, do you have the deb-src URLs in %s.list" % distro)
return "Package lookup faild"
if apt.VersionCompare(maxp['Version'], p['Version']) < 0:
maxp = p
del parser

View File

@ -30,3 +30,5 @@ conf.registerChannelValue(conf.supybot.plugins.Webcal, 'doTopic',
registry.Boolean(False,"""Whether to manage the topic"""))
conf.registerGlobalValue(conf.supybot.plugins.Webcal, 'defaultChannel',
registry.String('',"""Default channel to determine schedule for /msg replies"""))
conf.registerGlobalValue(conf.supybot.plugins.Webcal, 'tzUrl',
registry.String('', """URL to the list of timezones supported by the Webcal plugin"""))

View File

@ -165,8 +165,8 @@ class Webcal(callbacks.Plugin):
if not url:
return
tzs = filter(lambda x: self._tzfilter(x.lower(),tz.lower()), pytz.all_timezones)
if not tzs or 'gmt' in tz.lower():
irc.error('Unknown timezone: %s - Full list: http://ubotu.ubuntu-nl.org/timezones.html' % tz)
if not tzs:
irc.error('Unknown timezone: %s - Full list: %s' % (tz, self.config.registryValue('tzUrl') or 'Value not set'))
return
newtopic = self.maketopic(c,tz=tzs[0])
events = self.filter(self.cache[url], msg.args[0])
@ -191,8 +191,8 @@ class Webcal(callbacks.Plugin):
if not url:
return
tzs = filter(lambda x: self._tzfilter(x.lower(),tz.lower()), pytz.all_timezones)
if not tzs or 'gmt' in tz.lower():
irc.error('Unknown timezone: %s - Full list: http://ubotu.ubuntu-nl.org/timezones.html' % tz)
if not tzs:
irc.error('Unknown timezone: %s - Full list: %s' % (tz, self.config.registryValue('tzUrl') or 'Value not set'))
return
now = datetime.datetime.now(pytz.UTC)
newtopic = self.maketopic(c,tz=tzs[0],num_events=1)