Merge branch 'master' into testing

This commit is contained in:
Valentin Lorentz 2011-08-14 10:55:55 +02:00
commit 0d97adadc4
2 changed files with 30 additions and 2 deletions

View File

@ -78,6 +78,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')
conf.registerChannelValue(RSS.announce, 'showLinks', conf.registerChannelValue(RSS.announce, 'showLinks',

View File

@ -184,9 +184,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)
@ -194,7 +214,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: