From: Giuseppe Bilotta Date: Tue, 13 Feb 2007 17:38:12 +0000 (+0000) Subject: quiz plugin: quiz refresh command to refresh the question pool for the current channel X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=5c42a7427e27a0aef771d90f040bce18d256f31d;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git quiz plugin: quiz refresh command to refresh the question pool for the current channel --- diff --git a/data/rbot/plugins/quiz.rb b/data/rbot/plugins/quiz.rb index 9a550ea8..65a52b91 100644 --- a/data/rbot/plugins/quiz.rb +++ b/data/rbot/plugins/quiz.rb @@ -294,7 +294,7 @@ class QuizPlugin < Plugin "Quiz game aministration commands (requires authentication): 'quiz autoask ' => enable/disable autoask mode. 'quiz autoask delay ' => delay next quiz by seconds when in autoask mode. 'quiz transfer [score] [jokers]' => transfer [score] points and [jokers] jokers from to (default is entire score and all jokers). 'quiz setscore ' => set 's score to . 'quiz setjokers ' => set 's number of jokers to . 'quiz deleteplayer ' => delete one player from the rank table (only works when score and jokers are set to 0)." else urls = @bot.config['quiz.sources'].select { |p| p =~ /^https?:\/\// } - "A multiplayer trivia quiz. 'quiz' => ask a question. 'quiz hint' => get a hint. 'quiz solve' => solve this question. 'quiz skip' => skip to next question. 'quiz joker' => draw a joker to win this round. 'quiz score [player]' => show score for [player] (default is yourself). 'quiz top5' => show top 5 players. 'quiz top ' => show top players (max 50). 'quiz stats' => show some statistics. 'quiz fetch' => refetch questions from databases." + (urls.empty? ? "" : "\nYou can add new questions at #{urls.join(', ')}") + "A multiplayer trivia quiz. 'quiz' => ask a question. 'quiz hint' => get a hint. 'quiz solve' => solve this question. 'quiz skip' => skip to next question. 'quiz joker' => draw a joker to win this round. 'quiz score [player]' => show score for [player] (default is yourself). 'quiz top5' => show top 5 players. 'quiz top ' => show top players (max 50). 'quiz stats' => show some statistics. 'quiz fetch' => refetch questions from databases. 'quiz refresh' => refresh the question pool for this channel." + (urls.empty? ? "" : "\nYou can add new questions at #{urls.join(', ')}") end end @@ -493,7 +493,7 @@ class QuizPlugin < Plugin else q.canonical_answer = q.answers.first end - + q.first_try = true # FIXME 2.0 UTF-8 @@ -637,6 +637,14 @@ class QuizPlugin < Plugin end + def cmd_refresh( m, params ) + q = create_quiz ( m.channel ) + q.questions.clear + fetch_data ( m ) + cmd_quiz( m, params ) + end + + def cmd_top5( m, params ) chan = m.channel q = create_quiz( chan ) @@ -906,6 +914,7 @@ plugin.map 'quiz joker', :action => 'cmd_joker' plugin.map 'quiz score', :action => 'cmd_score' plugin.map 'quiz score :player', :action => 'cmd_score_player' plugin.map 'quiz fetch', :action => 'cmd_fetch' +plugin.map 'quiz refresh', :action => 'cmd_refresh' plugin.map 'quiz top5', :action => 'cmd_top5' plugin.map 'quiz top :number', :action => 'cmd_top_number' plugin.map 'quiz stats', :action => 'cmd_stats'