diff options
Diffstat (limited to 'bot')
-rw-r--r-- | bot/ircmeeting/agenda.py | 22 | ||||
-rw-r--r-- | bot/ircmeeting/meeting.py | 10 | ||||
-rw-r--r-- | bot/tests/run_test.py | 2 | ||||
-rw-r--r-- | bot/tests/test_scripts/council_only_actions.json | 7 |
4 files changed, 29 insertions, 12 deletions
diff --git a/bot/ircmeeting/agenda.py b/bot/ircmeeting/agenda.py index 05e4a57..ffd028c 100644 --- a/bot/ircmeeting/agenda.py +++ b/bot/ircmeeting/agenda.py @@ -62,9 +62,11 @@ class Agenda(object): match.group(3), irc) self._agenda[self._current_item][2] = '' - def next_agenda_item(self, irc): + def next_agenda_item(self, nick, irc): if not self.conf.manage_agenda: return('') + if not nick in self._voters: + return str.format(self.can_not_vote_msg, ", ".join(self._voters)) if self._vote_open: return self.voting_open_so_item_not_changed_msg else: @@ -72,9 +74,11 @@ class Agenda(object): self._swich_agenda_item_to(self._current_item + 1, irc) return(self.get_agenda_item()) - def prev_agenda_item(self, irc): + def prev_agenda_item(self, nick, irc): if not self.conf.manage_agenda: return('') + if not nick in self._voters: + return str.format(self.can_not_vote_msg, ", ".join(self._voters)) if self._vote_open: return self.voting_open_so_item_not_changed_msg else: @@ -82,17 +86,21 @@ class Agenda(object): self._swich_agenda_item_to(self._current_item - 1, irc) return(self.get_agenda_item()) - def start_vote(self): + def start_vote(self, nick): if not self.conf.manage_agenda: return('') + if not nick in self._voters: + return str.format(self.can_not_vote_msg, ", ".join(self._voters)) if self._vote_open: return self.voting_already_open_msg self._vote_open = True return str.format(self.voting_open_msg, self.options()) - def end_vote(self): + def end_vote(self, nick): if not self.conf.manage_agenda: return('') + if not nick in self._voters: + return str.format(self.can_not_vote_msg, ", ".join(self._voters)) if self._vote_open: self._vote_open = False return self.voting_close_msg @@ -125,7 +133,7 @@ class Agenda(object): reply = str.format(self.vote_confirm_msg, opt, self._agenda[self._current_item][1][opt]) if users_who_voted == self._voters: - reply += '. ' + self.end_vote() + reply += '. ' + self.end_vote(nick) return(reply) def _get_json(self, url): @@ -169,9 +177,11 @@ class Agenda(object): options_list.append(option_text) return str.format(self.added_option_msg, option_text) - def change_agenda_item(self, line): + def change_agenda_item(self, nick, line): if not self.conf.manage_agenda: return('') + if not nick in self._voters: + return str.format(self.can_not_vote_msg, ", ".join(self._voters)) if self._vote_open: return self.voting_open_so_item_not_changed_msg opt = self._to_agenda_item_number(line) diff --git a/bot/ircmeeting/meeting.py b/bot/ircmeeting/meeting.py index c20fd6d..6440ca2 100644 --- a/bot/ircmeeting/meeting.py +++ b/bot/ircmeeting/meeting.py @@ -324,11 +324,11 @@ class MeetingCommands(object): def do_nextitem(self, nick, time_, line, **kwargs): """Go to next agenda item""" - self.reply(self.config.agenda.next_agenda_item(self)) + self.reply(self.config.agenda.next_agenda_item(nick, self)) def do_previtem(self, nick, time_, line, **kwargs): """Go to previous agenda item""" - self.reply(self.config.agenda.prev_agenda_item(self)) + self.reply(self.config.agenda.prev_agenda_item(nick, self)) def do_timelimit(self, nick, time_, line, **kwargs): """ Manage reminders: @@ -352,16 +352,16 @@ class MeetingCommands(object): def do_changeitem(self, nick, time_, line, **kwargs): """Change agenda item. Usage: #chengeitem <item number>""" - self.reply(self.config.agenda.change_agenda_item(line)) + self.reply(self.config.agenda.change_agenda_item(nick, line)) def do_startvote(self, nick, time_, line, **kwargs): """Start vote on current item""" - for messageline in self.config.agenda.start_vote().split('\n'): + for messageline in self.config.agenda.start_vote(nick).split('\n'): self.reply(messageline) def do_endvote(self, nick, time_, line, **kwargs): """Close voting for current agenda item. You can resume voting later with #startvote""" - for messageline in self.config.agenda.end_vote().split('\n'): + for messageline in self.config.agenda.end_vote(nick).split('\n'): self.reply(messageline) def do_vote(self, nick, time_, line, **kwargs): diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py index a6077cb..dafcda3 100644 --- a/bot/tests/run_test.py +++ b/bot/tests/run_test.py @@ -326,7 +326,7 @@ class MeetBotTest(unittest.TestCase): def test_message_answer_tests(self): files = ['agenda_item_changing', 'agenda_option_listing', 'agenda_option_adding', 'agenda_option_removing', - 'close_voting_after_last_vote'] + 'close_voting_after_last_vote', 'council_only_actions'] for file in files: test = self.get_simple_agenda_test() test.check_responses_from_json_file(file) diff --git a/bot/tests/test_scripts/council_only_actions.json b/bot/tests/test_scripts/council_only_actions.json new file mode 100644 index 0000000..ce843a9 --- /dev/null +++ b/bot/tests/test_scripts/council_only_actions.json @@ -0,0 +1,7 @@ +[ +["20:13:50 <y> #nextitem", "You can not vote or change agenda. Only x, z can."], +["20:13:50 <y> #previtem", "You can not vote or change agenda. Only x, z can."], +["20:13:50 <y> #changeitem 1", "You can not vote or change agenda. Only x, z can."], +["20:13:50 <y> #startvote", "You can not vote or change agenda. Only x, z can."], +["20:13:50 <y> #endvote", "You can not vote or change agenda. Only x, z can."] +] |