From 87c4514e5fbe9eeea139a4bb7250755570f9adcb Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 13 Aug 2008 06:38:43 +0200 Subject: nickrecover plugin: work more than once per session --- data/rbot/plugins/nickrecover.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/data/rbot/plugins/nickrecover.rb b/data/rbot/plugins/nickrecover.rb index 02def493..ed3c8708 100644 --- a/data/rbot/plugins/nickrecover.rb +++ b/data/rbot/plugins/nickrecover.rb @@ -52,17 +52,25 @@ class NickRecoverPlugin < Plugin end def stop_recovery - @bot.timer.remove(@recovery) if @recovery + begin + @bot.timer.remove(@recovery) if @recovery + ensure + @recovery = nil + end end def start_recovery(time=self.poll_time) if @recovery - @bot.timer.reschedule(@recovery, poll_time) - else - @recovery = @bot.timer.add(time) do - has_nick? ? stop_recovery : recover + begin + @bot.timer.reschedule(@recovery, poll_time) + return + rescue + @recovery=nil end end + @recovery = @bot.timer.add(time) do + has_nick? ? stop_recovery : recover + end end def initialize -- cgit v1.2.3