mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
RSS: Register feed config in config.py instead of plugin.py.
So they are not dropped if plugin.py fails to load before feedparser is not installed. Closes GH-1387.
This commit is contained in:
parent
8001de6960
commit
f85287771d
@ -115,4 +115,27 @@ conf.registerChannelValue(RSS, 'keywordBlacklist',
|
||||
in this blacklist.""")))
|
||||
|
||||
|
||||
def register_feed_config(name, url=''):
|
||||
RSS.feeds().add(name)
|
||||
conf.registerGlobalValue(RSS.feeds, name,
|
||||
registry.String(url, _("""The URL for the feed %s. Note that because
|
||||
announced lines are cached, you may need to reload this plugin after
|
||||
changing this option.""" % name)))
|
||||
feed_group = conf.registerGroup(RSS.feeds, name)
|
||||
conf.registerChannelValue(feed_group, 'format',
|
||||
registry.String('', _("""Feed-specific format. Defaults to
|
||||
supybot.plugins.RSS.format if empty.""")))
|
||||
conf.registerChannelValue(feed_group, 'announceFormat',
|
||||
registry.String('', _("""Feed-specific announce format.
|
||||
Defaults to supybot.plugins.RSS.announceFormat if empty.""")))
|
||||
conf.registerGlobalValue(feed_group, 'waitPeriod',
|
||||
registry.NonNegativeInteger(0, _("""If set to a non-zero
|
||||
value, overrides supybot.plugins.RSS.waitPeriod for this
|
||||
particular feed.""")))
|
||||
|
||||
for name in RSS.feeds():
|
||||
register_feed_config(name)
|
||||
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -62,6 +62,8 @@ if minisix.PY2:
|
||||
else:
|
||||
from urllib.request import ProxyHandler
|
||||
|
||||
from .config import register_feed_config
|
||||
|
||||
def get_feedName(irc, msg, args, state):
|
||||
if irc.isChannel(args[0]):
|
||||
state.errorInvalid('feed name', args[0], 'must not be channel names.')
|
||||
@ -194,8 +196,6 @@ class RSS(callbacks.Plugin):
|
||||
else:
|
||||
announced = {}
|
||||
for name in self.registryValue('feeds'):
|
||||
self.assert_feed_does_not_exist(name)
|
||||
self.register_feed_config(name)
|
||||
try:
|
||||
url = self.registryValue(registry.join(['feeds', name]))
|
||||
except registry.NonExistentRegistryEntry:
|
||||
@ -235,28 +235,6 @@ class RSS(callbacks.Plugin):
|
||||
feed.name)
|
||||
raise callbacks.Error(s)
|
||||
|
||||
def register_feed_config(self, name, url=''):
|
||||
self.registryValue('feeds').add(name)
|
||||
group = self.registryValue('feeds', value=False)
|
||||
conf.registerGlobalValue(group, name,
|
||||
registry.String(url, """The URL for the feed
|
||||
%s. Note that because
|
||||
announced lines are cached,
|
||||
you may need to reload this
|
||||
plugin after changing this
|
||||
option.""" % name))
|
||||
feed_group = conf.registerGroup(group, name)
|
||||
conf.registerChannelValue(feed_group, 'format',
|
||||
registry.String('', _("""Feed-specific format. Defaults to
|
||||
supybot.plugins.RSS.format if empty.""")))
|
||||
conf.registerChannelValue(feed_group, 'announceFormat',
|
||||
registry.String('', _("""Feed-specific announce format.
|
||||
Defaults to supybot.plugins.RSS.announceFormat if empty.""")))
|
||||
conf.registerGlobalValue(feed_group, 'waitPeriod',
|
||||
registry.NonNegativeInteger(0, _("""If set to a non-zero
|
||||
value, overrides supybot.plugins.RSS.waitPeriod for this
|
||||
particular feed.""")))
|
||||
|
||||
def register_feed(self, name, url, initial,
|
||||
plugin_is_loading, announced=None):
|
||||
self.feed_names[name] = url
|
||||
@ -468,7 +446,7 @@ class RSS(callbacks.Plugin):
|
||||
given URL.
|
||||
"""
|
||||
self.assert_feed_does_not_exist(name, url)
|
||||
self.register_feed_config(name, url)
|
||||
register_feed_config(name, url)
|
||||
self.register_feed(name, url, True, False)
|
||||
irc.replySuccess()
|
||||
add = wrap(add, ['feedName', 'url'])
|
||||
@ -525,7 +503,7 @@ class RSS(callbacks.Plugin):
|
||||
for name in feeds:
|
||||
feed = plugin.get_feed(name)
|
||||
if not feed:
|
||||
plugin.register_feed_config(name, name)
|
||||
register_feed_config(name, name)
|
||||
plugin.register_feed(name, name, True, False)
|
||||
feed = plugin.get_feed(name)
|
||||
plugin.announce_feed(feed, True)
|
||||
|
Loading…
Reference in New Issue
Block a user