From 052217de30c59206d7025b582d4604557a747470 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 3 Feb 2011 12:53:34 +0100 Subject: [PATCH] quiz: stop quizzes and timers on cleanup This prevents spurious timers from running after a rescan --- data/rbot/plugins/games/quiz.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 ) -- 2.39.2