]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
quiz: autoask status query
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 3 Feb 2011 09:01:55 +0000 (10:01 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Thu, 3 Feb 2011 09:01:55 +0000 (10:01 +0100)
data/rbot/plugins/games/quiz.rb

index d2e4ab97970bec1e8bfefe6a9dedf849c1246d24..e1e544f4c9f1b2b244cef94ad7ba21d03db6e877 100644 (file)
@@ -735,6 +735,8 @@ class QuizPlugin < Plugin
       return
     end
 
+    params[:enable] ||= 'status'
+
     case params[:enable].downcase
     when "on", "true"
       q.registry_conf["autoask"] = true
@@ -743,8 +745,13 @@ class QuizPlugin < Plugin
     when "off", "false"
       q.registry_conf["autoask"] = false
       m.reply "Disabled autoask mode."
+    when "status"
+      m.reply _("Autoask is %{status}, the delay is %{time}") % {
+        :status => q.registry_conf["autoask"],
+        :time => Utils.secs_to_string(q.registry_conf["autoask_delay"]),
+      }
     else
-      m.reply "Invalid autoask parameter. Use 'on' or 'off'."
+      m.reply "Invalid autoask parameter. Use 'on' or 'off' to set it, 'status' to check the current status."
     end
   end
 
@@ -761,7 +768,6 @@ class QuizPlugin < Plugin
     m.reply "Autoask delay now #{q.registry_conf['autoask_delay']} seconds"
   end
 
-
   def cmd_transfer( m, params )
     chan = m.channel
     q = create_quiz( chan )
@@ -967,7 +973,7 @@ plugin.map 'quiz stats',            :action => 'cmd_stats'
 plugin.map 'quiz stop', :action => :stop
 
 # Admin commands
-plugin.map 'quiz autoask :enable',  :action => 'cmd_autoask', :auth_path => 'edit'
+plugin.map 'quiz autoask [:enable]',  :action => 'cmd_autoask', :auth_path => 'edit'
 plugin.map 'quiz autoask delay :time',  :action => 'cmd_autoask_delay', :auth_path => 'edit', :requirements => {:time => /\d+/}
 plugin.map 'quiz transfer :source :dest :score :jokers', :action => 'cmd_transfer', :auth_path => 'edit', :defaults => {:score => '-1', :jokers => '-1'}
 plugin.map 'quiz deleteplayer :nick', :action => 'cmd_del_player', :auth_path => 'edit'