From 398935bfe28ac7b7ef3f92a6535b19761267aa81 Mon Sep 17 00:00:00 2001 From: Mark Kretschmann Date: Wed, 20 Sep 2006 07:47:33 +0000 Subject: Quiz plugin: Improve error handling. --- data/rbot/plugins/quiz.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/quiz.rb b/data/rbot/plugins/quiz.rb index eeef338e..83e6ff92 100644 --- a/data/rbot/plugins/quiz.rb +++ b/data/rbot/plugins/quiz.rb @@ -482,8 +482,10 @@ class QuizPlugin < Plugin def cmd_top5( m, params ) q = create_quiz( m.target.to_s ) - - debug q.rank_table.inspect + if q.rank_table.empty? + m.reply "There are no scores known yet!" + return + end m.reply "* Top 5 Players for #{m.target.to_s}:" @@ -500,8 +502,10 @@ class QuizPlugin < Plugin num = params[:number].to_i return unless 1..50 === num q = create_quiz( m.target.to_s ) - - debug q.rank_table.inspect + if q.rank_table.empty? + m.reply "There are no scores known yet!" + return + end ar = [] m.reply "* Top #{num} Players for #{m.target.to_s}:" @@ -512,13 +516,7 @@ class QuizPlugin < Plugin score = player[1].score ar << "#{i + 1}. #{unhilight_nick( nick )} (#{score})" end - str = ar.join(" | ") - - if str.empty? - m.reply "Noone in #{m.target.to_s} has a score!" - else - m.reply str - end + m.reply ar.join(" | ") end -- cgit v1.2.3