aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2011-06-20 18:58:30 +0200
committerPetteri Räty <petsku@petteriraty.eu>2011-06-22 10:22:05 +0300
commitbc787b2518ac4fedcffaaf24e14f04839c3d7d3a (patch)
tree71d1bd27d775c79ac18bbe2df7ef217d63bfe6b1 /bot/ircmeeting/agenda.py
parentClose voting when last user allowed to vote voted. (diff)
downloadcouncil-webapp-bc787b2518ac4fedcffaaf24e14f04839c3d7d3a.tar.gz
council-webapp-bc787b2518ac4fedcffaaf24e14f04839c3d7d3a.tar.bz2
council-webapp-bc787b2518ac4fedcffaaf24e14f04839c3d7d3a.zip
Add #changeitem <no> command to MeetBot
Diffstat (limited to 'bot/ircmeeting/agenda.py')
-rw-r--r--bot/ircmeeting/agenda.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/bot/ircmeeting/agenda.py b/bot/ircmeeting/agenda.py
index 775dfd9..af03c3a 100644
--- a/bot/ircmeeting/agenda.py
+++ b/bot/ircmeeting/agenda.py
@@ -15,8 +15,8 @@ class Agenda(object):
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"
can_not_vote_msg = "You can not vote or change agenda. Only {} can."
- not_a_number_msg = "Your vote was not recognized as a number. Please retry."
- out_of_range_msg = "Your vote was out of range!"
+ not_a_number_msg = "Your choice was not recognized as a number. Please retry."
+ out_of_range_msg = "Your choice was out of range!"
vote_confirm_msg = "You voted for #{} - {}"
# Internal
@@ -109,14 +109,20 @@ class Agenda(object):
result = json.loads(str)
return result
- def _to_voting_option_number(self, line):
+ def _to_number(self, line, upper_limit):
if not line.isdigit():
return self.not_a_number_msg
opt = int(line)
- if opt < 0 or opt >= len(self._agenda[self._current_item][1]):
+ if opt < 0 or opt >= upper_limit:
return self.out_of_range_msg
return(opt)
+ def _to_voting_option_number(self, line):
+ return(self._to_number(line, len(self._agenda[self._current_item][1])))
+
+ def _to_agenda_item_number(self, line):
+ return(self._to_number(line, len(self._agenda)))
+
def options(self):
options_list = self._agenda[self._current_item][1]
n = len(options_list)
@@ -138,6 +144,17 @@ class Agenda(object):
options_list.append(option_text)
return str.format(self.added_option_msg, option_text)
+ def change_agenda_item(self, line):
+ if not self.conf.manage_agenda:
+ return('')
+ if self._vote_open:
+ return self.voting_open_so_item_not_changed_msg
+ opt = self._to_agenda_item_number(line)
+ if opt.__class__ is not int:
+ return(opt)
+ self._current_item = opt
+ return(self.get_agenda_item())
+
def remove_option(self, nick, line):
if not self.conf.manage_agenda:
return('')