From ed31d1494d548812eda0a381d84996f915533280 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Sun, 4 Dec 2016 11:35:59 +0000 Subject: [PATCH] Moved rss command to feed time. --- app.py | 11 +---------- plugin/feeds/feeds.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index 1181e42..7b005c2 100644 --- a/app.py +++ b/app.py @@ -154,15 +154,6 @@ def do_commands(message, command, raw, non_admin): idletime.value = int(m.group(1)) - elif command == 'rss': - # rss - m = re.match(r'\brss\s+(\d+)\b', raw, re.IGNORECASE) - if m is None: - yield from bot.say(message.channel, 'Sorry!') - return - - rsstime.value = int(m.group(1)) - elif command == 'time': # time yield from bot.say(message.channel, bot.iso8601(int(time.time()))) @@ -210,7 +201,7 @@ modules = { 'admin': { 'fn': do_commands, 'args': [False], - 'commands': ['avatar', 'delete', 'idle', 'rss'] + 'commands': ['avatar', 'delete', 'idle'] }, 'any': { 'fn': do_commands, diff --git a/plugin/feeds/feeds.py b/plugin/feeds/feeds.py index c8ee847..0400754 100644 --- a/plugin/feeds/feeds.py +++ b/plugin/feeds/feeds.py @@ -235,6 +235,8 @@ class Feeds(DBConnection): yield from self.create_new_feed(message, args) elif command == 'edit': yield from self.edit_existing_feed(message, args) + elif command == 'time': + yield from self.set_poll_time(message, args[1]) else: yield from cat.yelp(message.channel) @@ -273,6 +275,10 @@ class Feeds(DBConnection): log.debug('Member {} with role {} on server {} can manage feeds.'.format(member.name, member_role.name, server.name)) return feed + if command in ['time']: + if bot.is_admin(member, member.server): + return True + yield from cat.hiss(channel) return False @@ -515,6 +521,14 @@ class Feeds(DBConnection): yield from cat.yelp(message.channel) @asyncio.coroutine + def set_poll_time(self, message, *args): + seconds = bot.parse_seconds(args[0]) + if seconds < 60: + yield from bot.say(message.channel, 'At least 60!') + else: + rsstime.value = seconds + + @asyncio.coroutine def help_feeds(self, message, command = None): if command is None: lines = [ -- 2.7.4