diff options
author | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-07-16 20:21:26 +0200 |
---|---|---|
committer | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-07-16 20:21:26 +0200 |
commit | 6fd62e887e49accc1d3189279f0e007fed3f3bd1 (patch) | |
tree | 317898584b622296557b854bb3d126948327921f | |
parent | Fix warning coming from outdated will_paginate gem (diff) | |
download | council-webapp-6fd62e887e49accc1d3189279f0e007fed3f3bd1.tar.gz council-webapp-6fd62e887e49accc1d3189279f0e007fed3f3bd1.tar.bz2 council-webapp-6fd62e887e49accc1d3189279f0e007fed3f3bd1.zip |
Add #command command to MeetBot - shows documentation for other commands
-rw-r--r-- | bot/ircmeeting/meeting.py | 31 | ||||
-rw-r--r-- | bot/tests/run_test.py | 15 |
2 files changed, 39 insertions, 7 deletions
diff --git a/bot/ircmeeting/meeting.py b/bot/ircmeeting/meeting.py index a15b674..c20fd6d 100644 --- a/bot/ircmeeting/meeting.py +++ b/bot/ircmeeting/meeting.py @@ -323,14 +323,20 @@ class MeetingCommands(object): self.reply(self.config.agenda.get_agenda_item()) def do_nextitem(self, nick, time_, line, **kwargs): + """Go to next agenda item""" self.reply(self.config.agenda.next_agenda_item(self)) def do_previtem(self, nick, time_, line, **kwargs): + """Go to previous 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 ' +\ - '"#timelimit list" or "#timelimit remove <message>"' + """ Manage reminders: + #timelimit list - list all active reminders + #timelimit add <minutes>:<seconds> <message> - add a new reminder + #timelimit remove <message> - remove reminder with message""" + + reply = self.do_timelimit.__doc__ match = re.match( ' *?add ([0-9]+):([0-9]+) (.*)', line) if match: reply = self.config.agenda.add_timelimit(int(match.group(1)), @@ -341,24 +347,33 @@ class MeetingCommands(object): match = re.match( ' *?remove (.*)', line) if(match): reply = self.config.agenda.remove_timelimit(match.group(1)) - self.reply(reply) + for line in reply.split("\n"): + self.reply(line) def do_changeitem(self, nick, time_, line, **kwargs): + """Change agenda item. Usage: #chengeitem <item number>""" self.reply(self.config.agenda.change_agenda_item(line)) def do_startvote(self, nick, time_, line, **kwargs): + """Start vote on current item""" for messageline in self.config.agenda.start_vote().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'): self.reply(messageline) def do_vote(self, nick, time_, line, **kwargs): + """Make a vote. Usage: vote <option number>. Remember to #startvote before voting.""" for messageline in self.config.agenda.vote(nick, line).split('\n'): self.reply(messageline) def do_option(self, nick, time_, line, **kwargs): + """Manage voting options: + #option list - lists all available votin options for current item + #option add <option text> - adds new voting option + #option remove <option number> - removes existing option""" if re.match( ' *?list', line): result = self.config.agenda.options() elif re.match( ' *?add .*', line): @@ -515,6 +530,16 @@ class MeetingCommands(object): commands = [ "#"+x[3:] for x in dir(self) if x[:3]=="do_" ] commands.sort() self.reply("Available commands: "+(" ".join(commands))) + def do_command(self, nick, line, **kwargs): + name = "do_" + line.strip() + attr = getattr(self, name) + if attr is None: + return + doc = attr.__doc__ + if doc is None: + return + for line in doc.split("\n"): + self.reply(line) diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py index 0d18cce..136e135 100644 --- a/bot/tests/run_test.py +++ b/bot/tests/run_test.py @@ -450,10 +450,7 @@ class MeetBotTest(unittest.TestCase): def test_agenda_time_limit_adding(self): test = self.get_simple_agenda_test() - test.answer_should_match('20:13:50 <x> #timelimit', 'Usage "#timelimit ' +\ - 'add <minutes>:<seconds> <message>" or "' +\ - '#timelimit list" or "#timelimit remove ' +\ - '<message>"') + test.answer_should_match('20:13:50 <x> #timelimit', test.M.do_timelimit.__doc__) test.answer_should_match('20:13:50 <x> #timelimit add 0:1 some other message', 'Added "some other message" reminder in 0:1') test.answer_should_match('20:13:50 <x> #timelimit add 1:0 some message', @@ -531,6 +528,16 @@ class MeetBotTest(unittest.TestCase): error_msg = 'Received messages ' + str(test.log) + \ ' didn\'t match expected ' + str(expected_messages) assert messages_match, error_msg + def test_command_help(self): + test = self.get_simple_agenda_test() + commands = ['startmeeting', 'startvote', 'vote', 'endvote', + 'nextitem', 'previtem', 'changeitem', 'option', + 'timelimit', 'endmeeting'] + for command in commands: + desc = getattr(test.M, 'do_' + command).__doc__ + if desc is None: + desc = '' + test.answer_should_match('20:13:50 <x> #command ' + command, desc) if __name__ == '__main__': os.chdir(os.path.join(os.path.dirname(__file__), '.')) |