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:
parent
c2be01c5c0
commit
9fa81121c8
|
@ -88,6 +88,9 @@ class Apt:
|
||||||
parser = FeedParser.FeedParser()
|
parser = FeedParser.FeedParser()
|
||||||
parser.feed(p)
|
parser.feed(p)
|
||||||
p = parser.close()
|
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:
|
if apt.VersionCompare(maxp['Version'], p['Version']) < 0:
|
||||||
maxp = p
|
maxp = p
|
||||||
del parser
|
del parser
|
||||||
|
|
|
@ -30,3 +30,5 @@ conf.registerChannelValue(conf.supybot.plugins.Webcal, 'doTopic',
|
||||||
registry.Boolean(False,"""Whether to manage the topic"""))
|
registry.Boolean(False,"""Whether to manage the topic"""))
|
||||||
conf.registerGlobalValue(conf.supybot.plugins.Webcal, 'defaultChannel',
|
conf.registerGlobalValue(conf.supybot.plugins.Webcal, 'defaultChannel',
|
||||||
registry.String('',"""Default channel to determine schedule for /msg replies"""))
|
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"""))
|
||||||
|
|
|
@ -165,8 +165,8 @@ class Webcal(callbacks.Plugin):
|
||||||
if not url:
|
if not url:
|
||||||
return
|
return
|
||||||
tzs = filter(lambda x: self._tzfilter(x.lower(),tz.lower()), pytz.all_timezones)
|
tzs = filter(lambda x: self._tzfilter(x.lower(),tz.lower()), pytz.all_timezones)
|
||||||
if not tzs or 'gmt' in tz.lower():
|
if not tzs:
|
||||||
irc.error('Unknown timezone: %s - Full list: http://ubotu.ubuntu-nl.org/timezones.html' % tz)
|
irc.error('Unknown timezone: %s - Full list: %s' % (tz, self.config.registryValue('tzUrl') or 'Value not set'))
|
||||||
return
|
return
|
||||||
newtopic = self.maketopic(c,tz=tzs[0])
|
newtopic = self.maketopic(c,tz=tzs[0])
|
||||||
events = self.filter(self.cache[url], msg.args[0])
|
events = self.filter(self.cache[url], msg.args[0])
|
||||||
|
@ -191,8 +191,8 @@ class Webcal(callbacks.Plugin):
|
||||||
if not url:
|
if not url:
|
||||||
return
|
return
|
||||||
tzs = filter(lambda x: self._tzfilter(x.lower(),tz.lower()), pytz.all_timezones)
|
tzs = filter(lambda x: self._tzfilter(x.lower(),tz.lower()), pytz.all_timezones)
|
||||||
if not tzs or 'gmt' in tz.lower():
|
if not tzs:
|
||||||
irc.error('Unknown timezone: %s - Full list: http://ubotu.ubuntu-nl.org/timezones.html' % tz)
|
irc.error('Unknown timezone: %s - Full list: %s' % (tz, self.config.registryValue('tzUrl') or 'Value not set'))
|
||||||
return
|
return
|
||||||
now = datetime.datetime.now(pytz.UTC)
|
now = datetime.datetime.now(pytz.UTC)
|
||||||
newtopic = self.maketopic(c,tz=tzs[0],num_events=1)
|
newtopic = self.maketopic(c,tz=tzs[0],num_events=1)
|
||||||
|
|
Loading…
Reference in New Issue