+
+ def cmd_autoskip( m, params )
+ chan = m.channel
+ q = create_quiz( chan, m )
+ return unless q
+
+ params[:enable] ||= 'status'
+
+ reg = q.registry_conf
+
+ case params[:enable].downcase
+ when "on", "true"
+ reg["autoskip"] = true
+ m.reply "Enabled autoskip mode."
+ # default: 1 minute (TODO customize with a global config key)
+ reg["autoskip_delay"] = 60 unless reg.has_key("autoskip_delay")
+ cmd_quiz( m, nil ) if q.question == nil
+ when "off", "false"
+ reg["autoskip"] = false
+ m.reply "Disabled autoskip mode."
+ when "status"
+ if reg.has_key? "autoskip"
+ m.reply _("autoskip is %{status}, the delay is %{time}") % {
+ :status => reg["autoskip"],
+ :time => Utils.secs_to_string(reg["autoskip_delay"]),
+ }
+ else
+ m.reply _("autoskip is not configured here")
+ end
+ else
+ m.reply "Invalid autoskip parameter. Use 'on' or 'off' to set it, 'status' to check the current status."
+ end
+ end
+
+ def cmd_autoskip_delay( m, params )
+ chan = m.channel
+ q = create_quiz( chan, m )
+ return unless q
+
+ time = params[:time].to_s
+ if time =~ /^-?\d+$/
+ delay = time.to_i
+ else
+ begin
+ delay = Utils.parse_time_offset(time)
+ rescue RuntimeError
+ m.reply _("I couldn't understand that delay expression, sorry")
+ return
+ end
+ end
+
+ if delay < 0
+ m.reply _("wait, you want me to skip to the next question %{abs} BEFORE the previous one?") % {
+ :abs => Utils.secs_to_string(-delay)
+ }
+ return
+ elsif delay == 0
+ m.reply _("sure, I'll ask all the questions at the same time! </sarcasm>")
+ return
+ end
+
+ q.registry_conf["autoskip_delay"] = delay
+ m.reply "autoskip delay now #{q.registry_conf['autoskip_delay']} seconds"
+ end
+
+