summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-02-03 12:53:34 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-02-03 12:53:34 +0100
commit052217de30c59206d7025b582d4604557a747470 (patch)
tree0b4d1986c56e4890144b383077cfd19657c5889d
parentf6b83f72f89d8789760bfaff7080123a1a6fb5de (diff)
quiz: stop quizzes and timers on cleanup
This prevents spurious timers from running after a rescan
-rw-r--r--data/rbot/plugins/games/quiz.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/data/rbot/plugins/games/quiz.rb b/data/rbot/plugins/games/quiz.rb
index f16d057f..b139c66a 100644
--- a/data/rbot/plugins/games/quiz.rb
+++ b/data/rbot/plugins/games/quiz.rb
@@ -175,6 +175,22 @@ class QuizPlugin < Plugin
@ask_mutex = Mutex.new
end
+ def cleanup
+ @ask_mutex.synchronize do
+ # purge all waiting timers
+ @waiting.each do |chan, t|
+ @bot.timer.remove t.first
+ @bot.say chan, _("stopped quiz timer")
+ end
+ @waiting.clear
+ end
+ chans = @quizzes.keys
+ @quizzes.clear
+ chans.each do |chan|
+ @bot.say chan, _("quiz stopped")
+ end
+ end
+
# Function that returns whether a char is a "separator", used for hints
#
def is_sep( ch )