diff options
author | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-06-16 16:31:05 +0200 |
---|---|---|
committer | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-06-16 17:06:46 +0200 |
commit | 2460e74c1a09fe988017437bbebdc8c6e5e41694 (patch) | |
tree | e4fec12153bcfb0924fcf9f34a416a93446c1ae5 /bot/ircmeeting/agenda.py | |
parent | Reminder plugin more testable + tests for it (diff) | |
download | council-webapp-2460e74c1a09fe988017437bbebdc8c6e5e41694.tar.gz council-webapp-2460e74c1a09fe988017437bbebdc8c6e5e41694.tar.bz2 council-webapp-2460e74c1a09fe988017437bbebdc8c6e5e41694.zip |
Add #option list command
Diffstat (limited to 'bot/ircmeeting/agenda.py')
-rw-r--r-- | bot/ircmeeting/agenda.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/bot/ircmeeting/agenda.py b/bot/ircmeeting/agenda.py index cfecc61..32ddb9f 100644 --- a/bot/ircmeeting/agenda.py +++ b/bot/ircmeeting/agenda.py @@ -7,7 +7,7 @@ class Agenda(object): empty_agenda_msg = "Agenda is empty so I can't help you manage meeting (and voting)." current_item_msg = "Current agenda item is {}." voting_already_open_msg = "Voting is already open. You can end it with #endvote." - voting_open_msg = "Voting started. Your choices are:{}Vote #vote <option number>.\nEnd voting with #endvote." + voting_open_msg = "Voting started. {}Vote #vote <option number>.\nEnd voting with #endvote." voting_close_msg = "Voting closed." voting_already_closed_msg = "Voting is already closed. You can start it with #startvote." voting_open_so_item_not_changed_msg = "Voting is currently open so I didn't change item. Please #endvote first" @@ -60,10 +60,7 @@ class Agenda(object): if self._vote_open: return self.voting_already_open_msg self._vote_open = True - options = "\n" - for i in range(len(self._agenda[self._current_item][1])): - options += str.format("{}. {}\n", i, self._agenda[self._current_item][1][i]) - return str.format(self.voting_open_msg, options) + return str.format(self.voting_open_msg, self.options()) def end_vote(self): if not self.conf.manage_agenda: @@ -104,6 +101,17 @@ class Agenda(object): result = json.loads(str) return result + def options(self): + options_list = self._agenda[self._current_item][1] + n = len(options_list) + if n == 0: + return 'No voting options available.' + else: + options = "Available voting options are:\n" + for i in range(n): + options += str.format("{}. {}\n", i, options_list[i]) + return options + def post_result(self): if not self.conf.manage_agenda: return('') |