diff options
author | 2011-06-24 19:37:23 +0200 | |
---|---|---|
committer | 2011-06-24 19:37:23 +0200 | |
commit | 4430af0e8a05b3424b88ee9803034959b5e46dec (patch) | |
tree | 5bac063f10d037fef5934c8e25e6ba6bd7acb8f5 | |
parent | Send timelimits to bot (diff) | |
download | council-webapp-4430af0e8a05b3424b88ee9803034959b5e46dec.tar.gz council-webapp-4430af0e8a05b3424b88ee9803034959b5e46dec.tar.bz2 council-webapp-4430af0e8a05b3424b88ee9803034959b5e46dec.zip |
Bot receives reminders from webapp
-rw-r--r-- | bot/ircmeeting/agenda.py | 18 | ||||
-rw-r--r-- | bot/ircmeeting/meeting.py | 4 | ||||
-rw-r--r-- | bot/tests/run_test.py | 19 |
3 files changed, 32 insertions, 9 deletions
diff --git a/bot/ircmeeting/agenda.py b/bot/ircmeeting/agenda.py index 220acf9..101c73c 100644 --- a/bot/ircmeeting/agenda.py +++ b/bot/ircmeeting/agenda.py @@ -50,30 +50,36 @@ class Agenda(object): else: return self.empty_agenda_msg - def _swich_agenda_item_to(self, new_item): + def _swich_agenda_item_to(self, new_item, irc): self._current_item = new_item for reminder in self.reminders.values(): reminder.cancel() self.reminders = {} - - def next_agenda_item(self): + for line in self._agenda[self._current_item][2].split('\n'): + match = re.match( '([0-9]+):([0-9]+) (.*)', line) + if match: + self.add_timelimit(int(match.group(1)), int(match.group(2)), + match.group(3), irc) + self._agenda[self._current_item][2] = '' + + def next_agenda_item(self, irc): if not self.conf.manage_agenda: return('') if self._vote_open: return self.voting_open_so_item_not_changed_msg else: if (self._current_item + 1) < len(self._agenda): - self._swich_agenda_item_to(self._current_item + 1) + self._swich_agenda_item_to(self._current_item + 1, irc) return(self.get_agenda_item()) - def prev_agenda_item(self): + def prev_agenda_item(self, irc): if not self.conf.manage_agenda: return('') if self._vote_open: return self.voting_open_so_item_not_changed_msg else: if self._current_item > 0: - self._swich_agenda_item_to(self._current_item - 1) + self._swich_agenda_item_to(self._current_item - 1, irc) return(self.get_agenda_item()) def start_vote(self): diff --git a/bot/ircmeeting/meeting.py b/bot/ircmeeting/meeting.py index 4bd3221..e3cf38d 100644 --- a/bot/ircmeeting/meeting.py +++ b/bot/ircmeeting/meeting.py @@ -323,10 +323,10 @@ class MeetingCommands(object): self.reply(self.config.agenda.get_agenda_item()) def do_nextitem(self, nick, time_, line, **kwargs): - self.reply(self.config.agenda.next_agenda_item()) + self.reply(self.config.agenda.next_agenda_item(self)) def do_previtem(self, nick, time_, line, **kwargs): - self.reply(self.config.agenda.prev_agenda_item()) + self.reply(self.config.agenda.prev_agenda_item(self)) def do_timelimit(self, nick, time_, line, **kwargs): reply = 'Usage "#timelimit add <minutes>:<seconds> <message>" or ' +\ diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py index e3a9030..e22516b 100644 --- a/bot/tests/run_test.py +++ b/bot/tests/run_test.py @@ -344,7 +344,7 @@ class MeetBotTest(unittest.TestCase): def get_simple_agenda_test(self): test = test_meeting.TestMeeting() test.set_voters(['x', 'z']) - test.set_agenda([['first item', ['opt1', 'opt2']], ['second item', []]]) + test.set_agenda([['first item', ['opt1', 'opt2'], ''], ['second item', [], '']]) test.M.config.manage_agenda = False test.answer_should_match("20:13:50 <x> #startmeeting", @@ -483,6 +483,23 @@ class MeetBotTest(unittest.TestCase): test.answer_should_match('20:13:50 <x> #timelimit list', 'Set reminders: "' + '", "'.join(keys) + '"') + def test_preset_agenda_time_limits(self): + test = self.get_simple_agenda_test() + test.M.config.agenda._agenda[0][2] = '1:0 message' + test.M.config.agenda._agenda[1][2] = '1:0 another message\n0:10 some other message' + + test.process('20:13:50 <x> #nextitem') + keys = test.M.config.agenda.reminders.keys() + keys.sort() + assert(keys == ['another message', 'some other message']) + + test.process('20:13:50 <x> #previtem') + keys = test.M.config.agenda.reminders.keys() + keys.sort() + assert(keys == ['message']) + + test.process('20:13:50 <x> #nextitem') + if __name__ == '__main__': os.chdir(os.path.join(os.path.dirname(__file__), '.')) |