public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/council-webapp:master commit in: bot/tests/, bot/ircmeeting/
Date: Sat, 18 Jun 2011 15:46:13 +0000 (UTC)	[thread overview]
Message-ID: <55cfc31254373f2618a17f73e2923b2503514ecb.betelgeuse@gentoo> (raw)

commit:     55cfc31254373f2618a17f73e2923b2503514ecb
Author:     Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Thu Jun 16 15:36:01 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Jun 16 15:36:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=55cfc312

Add '#option add' command to MeetBot

---
 bot/ircmeeting/agenda.py  |   15 ++++++++++++++-
 bot/ircmeeting/meeting.py |    2 ++
 bot/tests/run_test.py     |   10 ++++++++++
 3 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/bot/ircmeeting/agenda.py b/bot/ircmeeting/agenda.py
index 32ddb9f..97bcfcf 100644
--- a/bot/ircmeeting/agenda.py
+++ b/bot/ircmeeting/agenda.py
@@ -1,9 +1,11 @@
 import json
 import urllib
+import re
 
 class Agenda(object):
 
     # Messages
+    added_option_msg = "You added new voting option: {}"
     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."
@@ -11,7 +13,7 @@ class Agenda(object):
     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"
-    can_not_vote_msg = "You can not vote. Only {} can vote"
+    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!"
     vote_confirm_msg = "You voted for #{} - {}"
@@ -111,6 +113,17 @@ class Agenda(object):
           for i in range(n):
               options += str.format("{}. {}\n", i, options_list[i])
           return options
+    def add_option(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))
+        options_list = self._agenda[self._current_item][1]
+        option_text = re.match( ' *?add (.*)', line).group(1)
+        options_list.append(option_text)
+        return str.format(self.added_option_msg, option_text)
+
+
 
     def post_result(self):
         if not self.conf.manage_agenda:

diff --git a/bot/ircmeeting/meeting.py b/bot/ircmeeting/meeting.py
index d8589c4..f9c907b 100644
--- a/bot/ircmeeting/meeting.py
+++ b/bot/ircmeeting/meeting.py
@@ -343,6 +343,8 @@ class MeetingCommands(object):
     def do_option(self, nick, time_, line, **kwargs):
         if re.match( ' *?list', line):
           result = self.config.agenda.options()
+        elif re.match( ' *?add .*', line):
+          result = self.config.agenda.add_option(nick, line)
         for messageline in result.split('\n'):
             self.reply(messageline)
 

diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py
index c28f1ae..a80e6ec 100644
--- a/bot/tests/run_test.py
+++ b/bot/tests/run_test.py
@@ -385,6 +385,16 @@ class MeetBotTest(unittest.TestCase):
         test.answer_should_match('20:13:50 <x> #option list', 'Available voting options ' +\
                                   'are:\n0. opt1\n1. opt2\n')
 
+    def test_agenda_option_adding(self):
+        test = self.get_simple_agenda_test()
+        test.process('20:13:50 <x> #nextitem')
+        test.answer_should_match('20:13:50 <not_allowed> #option add first option',
+                                  'You can not vote or change agenda. Only x, z can.')
+        test.answer_should_match('20:13:50 <x> #option add first option',
+                                  'You added new voting option: first option')
+        test.answer_should_match('20:13:50 <x> #option list', 'Available voting options ' +\
+                                  'are:\n0. first option')
+
     def test_agenda_voting(self):
         test = self.get_simple_agenda_test()
         test.answer_should_match('20:13:50 <x> #startvote', 'Voting started\. ' +\



             reply	other threads:[~2011-06-18 15:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-18 15:46 Petteri Räty [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-07-18  7:41 [gentoo-commits] proj/council-webapp:master commit in: bot/tests/, bot/ircmeeting/ Petteri Räty
2011-06-25 11:55 Petteri Räty
2011-06-25 11:55 Petteri Räty
2011-06-22  7:59 Petteri Räty
2011-06-22  7:59 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-05 20:37 Petteri Räty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55cfc31254373f2618a17f73e2923b2503514ecb.betelgeuse@gentoo \
    --to=betelgeuse@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox