1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

fix config problem, filter on short answers

This commit is contained in:
Thorsten
2016-01-31 22:22:41 +01:00
parent f51a34028f
commit 75f169c6c6

View File

@@ -21,12 +21,13 @@ def get_questions(directory=None):
return all_questions
def get_random_question(quizcfg):
def get_random_question():
with plugin_config('quiz') as quizcfg:
questions = get_questions()
# select a random question
used_ids = quizcfg.get('used_ids', [])
q_index = None
while q_index is None:
while q_index is None or len(questions[q_index+1].split()) > 2:
rand = random.choice(range(0, len(questions)-2, 2))
if rand not in used_ids:
q_index = rand
@@ -134,7 +135,7 @@ def start_random_question():
else:
quizcfg["locked"] = True
qa = get_random_question(quizcfg)
qa = get_random_question()
return {
'msg': ['Q: {}'.format(qa[0])],