From 50eb36e87609a0cb5854c692758cb1d69a4fc8d1 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Sun, 31 Jan 2016 19:29:58 +0100 Subject: [PATCH] add interval --- plugins/commands.py | 5 +++-- plugins/quiz.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/commands.py b/plugins/commands.py index d84fe2b..edaa177 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -911,7 +911,7 @@ def vote(argv, **args): @pluginfunction('quiz', 'play quiz', ptypes_COMMAND) def quiz_control(argv, **args): - usage = """quiz mode usage: "quiz start", "quiz stop", "quiz answer", "quiz skip", + usage = """quiz mode usage: "quiz start [secs interval]", "quiz stop", "quiz answer", "quiz skip", "quiz rules; if the quiz mode is active, sentences are parsed and compared against the answer. """ @@ -938,7 +938,8 @@ The answers will be matched by characters/words. Answers will be quizcfg = dict() if argv[0] == 'start': - return quiz.start_random_question(quizcfg) + interval = argv[1] if len(argv) > 1 else 60 + return quiz.start_random_question(quizcfg, interval) elif argv[0] == 'stop': return quiz.stop(quizcfg) elif argv[0] == 'answer': diff --git a/plugins/quiz.py b/plugins/quiz.py index ee96788..9af8bd1 100644 --- a/plugins/quiz.py +++ b/plugins/quiz.py @@ -115,7 +115,7 @@ def rate(quizcfg, response, user): # } -def start_random_question(quizcfg): +def start_random_question(quizcfg, interval): stop(quizcfg) qa = get_random_question(quizcfg) @@ -123,7 +123,7 @@ def start_random_question(quizcfg): 'msg': ['Q: {}'.format(qa[0])], 'event': { 'command': (end_question, ([quizcfg],)), - 'time': time.time() + 15 + 'time': time.time() + interval } }