mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
RSS: add 'announce channels' command to list channels a feed is announced to
Closes #1322.
This commit is contained in:
parent
ba6878375b
commit
3c23faf1bd
@ -550,6 +550,30 @@ class RSS(callbacks.Plugin):
|
|||||||
remove = wrap(remove, [('checkChannelCapability', 'op'),
|
remove = wrap(remove, [('checkChannelCapability', 'op'),
|
||||||
many(first('url', 'feedName'))])
|
many(first('url', 'feedName'))])
|
||||||
|
|
||||||
|
@internationalizeDocstring
|
||||||
|
def channels(self, irc, msg, args, feed):
|
||||||
|
"""<name|url>
|
||||||
|
|
||||||
|
Returns a list of channels that the given feed name or URL is being
|
||||||
|
announced to.
|
||||||
|
"""
|
||||||
|
plugin = irc.getCallback('RSS')
|
||||||
|
if not plugin.get_feed(feed):
|
||||||
|
irc.error(_("Unknown feed %s" % feed), Raise=True)
|
||||||
|
|
||||||
|
channels = []
|
||||||
|
for ircnet in world.ircs:
|
||||||
|
for channel in ircnet.state.channels:
|
||||||
|
if feed in plugin.registryValue('announce', channel, ircnet.network):
|
||||||
|
channels.append(ircnet.network + channel)
|
||||||
|
|
||||||
|
if channels:
|
||||||
|
irc.reply(format("%s is announced to %L.", feed, channels))
|
||||||
|
else:
|
||||||
|
irc.reply("%s is not announced to any channels." % feed)
|
||||||
|
|
||||||
|
channels = wrap(channels, ['feedName'])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def rss(self, irc, msg, args, url, n):
|
def rss(self, irc, msg, args, url, n):
|
||||||
"""<name|url> [<number of headlines>]
|
"""<name|url> [<number of headlines>]
|
||||||
|
@ -357,9 +357,15 @@ class RSSTestCase(ChannelPluginTestCase):
|
|||||||
timeFastForward(1.1)
|
timeFastForward(1.1)
|
||||||
self.assertNotError('rss add advogato %s' % url)
|
self.assertNotError('rss add advogato %s' % url)
|
||||||
self.assertNotError('rss announce add advogato')
|
self.assertNotError('rss announce add advogato')
|
||||||
|
self.assertRegexp('rss announce channels advogato', 'advogato is announced to.*%s%s' % (self.irc.network, self.channel))
|
||||||
|
|
||||||
self.assertNotRegexp('rss announce', r'ValueError')
|
self.assertNotRegexp('rss announce', r'ValueError')
|
||||||
|
|
||||||
self.assertNotError('rss announce remove advogato')
|
self.assertNotError('rss announce remove advogato')
|
||||||
|
self.assertRegexp('rss announce channels advogato', 'advogato is not announced to any channels')
|
||||||
|
|
||||||
self.assertNotError('rss remove advogato')
|
self.assertNotError('rss remove advogato')
|
||||||
|
self.assertRegexp('rss announce channels advogato', 'Unknown feed')
|
||||||
|
|
||||||
def testRss(self):
|
def testRss(self):
|
||||||
timeFastForward(1.1)
|
timeFastForward(1.1)
|
||||||
|
Loading…
Reference in New Issue
Block a user