mirror of https://github.com/Mikaela/Limnoria.git
Improved RSS.announce
This commit is contained in:
parent
9d4b715004
commit
27e3b07119
|
@ -1,3 +1,7 @@
|
||||||
|
* Improved the functionality of RSS.announce. Calling it with
|
||||||
|
no arguments now lists the currently announced feeds. Removing
|
||||||
|
feeds is done by specifying the --remove option.
|
||||||
|
|
||||||
* Added a reconnect command to the Owner plugin. It won't work
|
* Added a reconnect command to the Owner plugin. It won't work
|
||||||
for people using asyncoreDrivers, but those people should be few
|
for people using asyncoreDrivers, but those people should be few
|
||||||
and far between these days.
|
and far between these days.
|
||||||
|
|
|
@ -39,6 +39,7 @@ import plugins
|
||||||
|
|
||||||
import sets
|
import sets
|
||||||
import time
|
import time
|
||||||
|
import getopt
|
||||||
import sgmllib
|
import sgmllib
|
||||||
import threading
|
import threading
|
||||||
from itertools import imap
|
from itertools import imap
|
||||||
|
@ -64,6 +65,10 @@ def configure(advanced):
|
||||||
url = something('What\'s the URL of the RSS feed?')
|
url = something('What\'s the URL of the RSS feed?')
|
||||||
registerFeed(name, url)
|
registerFeed(name, url)
|
||||||
|
|
||||||
|
class AnnouncedFeeds(registry.SpaceSeparatedListOf):
|
||||||
|
Value = registry.String
|
||||||
|
List = ircutils.IrcSet
|
||||||
|
|
||||||
conf.registerPlugin('RSS')
|
conf.registerPlugin('RSS')
|
||||||
conf.registerChannelValue(conf.supybot.plugins.RSS, 'bold', registry.Boolean(
|
conf.registerChannelValue(conf.supybot.plugins.RSS, 'bold', registry.Boolean(
|
||||||
True, """Determines whether the bot will bold the title of the feed when it
|
True, """Determines whether the bot will bold the title of the feed when it
|
||||||
|
@ -76,9 +81,9 @@ conf.registerChannelValue(conf.supybot.plugins.RSS, 'announcementPrefix',
|
||||||
is prepended (if any) to the new news item announcements made in the
|
is prepended (if any) to the new news item announcements made in the
|
||||||
channel."""))
|
channel."""))
|
||||||
conf.registerChannelValue(conf.supybot.plugins.RSS, 'announce',
|
conf.registerChannelValue(conf.supybot.plugins.RSS, 'announce',
|
||||||
registry.SpaceSeparatedListOfStrings([], """Determines which RSS feeds
|
AnnouncedFeeds([], """Determines which RSS feeds should be announced in
|
||||||
should be announced in the channel; valid input is a list of strings
|
the channel; valid input is a list of strings (either registered RSS feeds
|
||||||
(either registered RSS feeds or RSS feed URLs) separated by spaces."""))
|
or RSS feed URLs) separated by spaces."""))
|
||||||
conf.registerGlobalValue(conf.supybot.plugins.RSS, 'waitPeriod',
|
conf.registerGlobalValue(conf.supybot.plugins.RSS, 'waitPeriod',
|
||||||
registry.PositiveInteger(1800, """Indicates how many seconds the bot will
|
registry.PositiveInteger(1800, """Indicates how many seconds the bot will
|
||||||
wait between retrieving RSS feeds; requests made within this period will
|
wait between retrieving RSS feeds; requests made within this period will
|
||||||
|
@ -100,7 +105,6 @@ class RSS(callbacks.Privmsg):
|
||||||
self.cachedFeeds = {}
|
self.cachedFeeds = {}
|
||||||
self.gettingLockLock = threading.Lock()
|
self.gettingLockLock = threading.Lock()
|
||||||
for (name, url) in registry._cache.iteritems():
|
for (name, url) in registry._cache.iteritems():
|
||||||
name = name.lower()
|
|
||||||
if name.startswith('supybot.plugins.rss.feeds.'):
|
if name.startswith('supybot.plugins.rss.feeds.'):
|
||||||
name = rsplit(name, '.', 1)[-1]
|
name = rsplit(name, '.', 1)[-1]
|
||||||
v = registry.String('', 'help is not needed here')
|
v = registry.String('', 'help is not needed here')
|
||||||
|
@ -290,19 +294,40 @@ class RSS(callbacks.Privmsg):
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
def announce(self, irc, msg, args, channel):
|
def announce(self, irc, msg, args, channel):
|
||||||
"""[<channel>] [<name|url> ...]
|
"""[<channel>] [--remove] [<name|url> ...]
|
||||||
|
|
||||||
Sets the current list of announced feeds in the channel to the feeds
|
Sets the current list of announced feeds in the channel to the feeds
|
||||||
given. Valid feeds include the names of registered feeds as well as
|
given. Valid feeds include the names of registered feeds as well as
|
||||||
URLs for a RSS feeds. <channel> is only necessary if the message isn't
|
URLs for a RSS feeds. <channel> is only necessary if the message isn't
|
||||||
sent in the channel itself.
|
sent in the channel itself. If no arguments are specified, replies
|
||||||
|
with the current list of feeds to announce. If --remove is given,
|
||||||
|
the specified feeds will be removed from the list of feeds to announce.
|
||||||
"""
|
"""
|
||||||
conf.supybot.plugins.RSS.announce.get(channel).setValue(args)
|
(optlist, rest) = getopt.getopt(args, '', ['remove'])
|
||||||
if not args:
|
remove = False
|
||||||
irc.replySuccess('All previously announced feeds will not be '
|
announce = conf.supybot.plugins.RSS.announce
|
||||||
'announced any longer.')
|
for (option, _) in optlist:
|
||||||
else:
|
if option == '--remove':
|
||||||
|
remove = True
|
||||||
|
if remove:
|
||||||
|
if rest:
|
||||||
|
feeds = announce.get(channel)()
|
||||||
|
for feed in rest:
|
||||||
|
if feed in feeds:
|
||||||
|
feeds.remove(feed)
|
||||||
|
announce.get(channel).setValue(feeds)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
raise callbacks.ArgumentError
|
||||||
|
elif not rest:
|
||||||
|
feeds = utils.commaAndify(announce.get(channel)())
|
||||||
|
irc.reply(feeds or 'I am currently not announcing any feeds.')
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
announce.get(channel).setValue(rest)
|
||||||
|
irc.replySuccess()
|
||||||
|
return
|
||||||
announce = privmsgs.checkChannelCapability(announce, 'op')
|
announce = privmsgs.checkChannelCapability(announce, 'op')
|
||||||
|
|
||||||
def rss(self, irc, msg, args):
|
def rss(self, irc, msg, args):
|
||||||
|
|
Loading…
Reference in New Issue