Skip to content

Commit

Permalink
[rss] Added fetch feature to pull all feeds manually.
Browse files Browse the repository at this point in the history
Will run whether or not regular fetching has been started.
  • Loading branch information
saltire committed Sep 11, 2013
1 parent 4b98667 commit ee39e5a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def __init__(self, bot):


def manage_rss(self, bot, trigger):
"""Manage RSS feeds. Usage: .rss <start|stop|add|del|clear|toggle|list>"""
"""Manage RSS feeds. Usage: .rss <start|stop|add|del|clear|toggle|list|fetch>"""
if not trigger.admin:
bot.reply("Sorry, you need to be an admin to modify the RSS feeds.")
return

actions = ('start', 'stop', 'add', 'del', 'clear', 'toggle', 'list')
actions = ('start', 'stop', 'add', 'del', 'clear', 'toggle', 'list', 'fetch')
text = trigger.group().split()
if (len(text) < 2 or text[1] not in actions):
bot.reply("Please specify an operation: " + ', '.join(actions))
Expand Down Expand Up @@ -292,6 +292,11 @@ def rss_list(self, bot, trigger, c):
feed.fg, feed.bg))


def rss_fetch(self, bot, trigger, c):
"""Force all RSS feeds to be fetched immediately. Usage: .rss fetch"""
read_feeds(bot, True)


class RSSFeed:
"""Represent a single row in the feed table."""

Expand All @@ -314,8 +319,8 @@ def __init__(self, row):


@interval(INTERVAL)
def read_feeds(bot):
if not bot.memory['rss_manager'].running:
def read_feeds(bot, force=False):
if not bot.memory['rss_manager'].running and not force:
return

sub = bot.db.substitution
Expand Down

0 comments on commit ee39e5a

Please sign in to comment.