mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
RSS: add channel-specific blacklist and whitelist.
also fix bug introduced with the initialannounce feature, which overwrote newheadlines list when doing channel-specific things with it.
This commit is contained in:
parent
e23bd93ded
commit
af32d6bfd3
@ -76,6 +76,14 @@ conf.registerGlobalValue(RSS, 'defaultNumberOfHeadlines',
|
|||||||
conf.registerChannelValue(RSS, 'initialAnnounceHeadlines',
|
conf.registerChannelValue(RSS, 'initialAnnounceHeadlines',
|
||||||
registry.PositiveInteger(5, """Indicates how many headlines an rss feed
|
registry.PositiveInteger(5, """Indicates how many headlines an rss feed
|
||||||
will output when it is first added to announce for a channel."""))
|
will output when it is first added to announce for a channel."""))
|
||||||
|
conf.registerChannelValue(RSS, 'keywordWhitelist',
|
||||||
|
registry.SpaceSeparatedSetOfStrings([], """Space separated list of
|
||||||
|
strings, lets you filter headlines to those containing one or more items
|
||||||
|
in this whitelist."""))
|
||||||
|
conf.registerChannelValue(RSS, 'keywordBlacklist',
|
||||||
|
registry.SpaceSeparatedSetOfStrings([], """Space separated list of
|
||||||
|
strings, lets you filter headlines to those not containing any items
|
||||||
|
in this blacklist."""))
|
||||||
|
|
||||||
|
|
||||||
conf.registerGroup(RSS, 'announce')
|
conf.registerGroup(RSS, 'announce')
|
||||||
|
@ -182,9 +182,29 @@ class RSS(callbacks.Plugin):
|
|||||||
newheadlines[i] = None
|
newheadlines[i] = None
|
||||||
newheadlines = filter(None, newheadlines) # Removes Nones.
|
newheadlines = filter(None, newheadlines) # Removes Nones.
|
||||||
if newheadlines:
|
if newheadlines:
|
||||||
|
def filter_whitelist(headline):
|
||||||
|
v = False
|
||||||
|
for kw in whitelist:
|
||||||
|
if kw in headline[0] or kw in headline[1]:
|
||||||
|
v = True
|
||||||
|
break
|
||||||
|
return v
|
||||||
|
def filter_blacklist(headline):
|
||||||
|
v = True
|
||||||
|
for kw in blacklist:
|
||||||
|
if kw in headline[0] or kw in headline[1]:
|
||||||
|
v = False
|
||||||
|
break
|
||||||
|
return v
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
if len(oldheadlines) == 0:
|
if len(oldheadlines) == 0:
|
||||||
newheadlines = newheadlines[:self.registryValue('initialAnnounceHeadlines', channel)]
|
channelnewheadlines = newheadlines[:self.registryValue('initialAnnounceHeadlines', channel)]
|
||||||
|
whitelist = self.registryValue('keywordWhitelist', channel)
|
||||||
|
blacklist = self.registryValue('keywordBlacklist', channel)
|
||||||
|
if len(whitelist) != 0:
|
||||||
|
channelnewheadlines = filter(filter_whitelist, channelnewheadlines)
|
||||||
|
if len(blacklist) != 0:
|
||||||
|
channelnewheadlines = filter(filter_blacklist, channelnewheadlines)
|
||||||
bold = self.registryValue('bold', channel)
|
bold = self.registryValue('bold', channel)
|
||||||
sep = self.registryValue('headlineSeparator', channel)
|
sep = self.registryValue('headlineSeparator', channel)
|
||||||
prefix = self.registryValue('announcementPrefix', channel)
|
prefix = self.registryValue('announcementPrefix', channel)
|
||||||
@ -192,7 +212,7 @@ class RSS(callbacks.Plugin):
|
|||||||
if bold:
|
if bold:
|
||||||
pre = ircutils.bold(pre)
|
pre = ircutils.bold(pre)
|
||||||
sep = ircutils.bold(sep)
|
sep = ircutils.bold(sep)
|
||||||
headlines = self.buildHeadlines(newheadlines, channel)
|
headlines = self.buildHeadlines(channelnewheadlines, channel)
|
||||||
irc.replies(headlines, prefixer=pre, joiner=sep,
|
irc.replies(headlines, prefixer=pre, joiner=sep,
|
||||||
to=channel, prefixNick=False, private=True)
|
to=channel, prefixNick=False, private=True)
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
Reference in New Issue
Block a user