From 0cc10dda002cdd1568aed585c38fa6cf63db77fd Mon Sep 17 00:00:00 2001 From: Dmitry Kim Date: Fri, 31 Aug 2007 23:59:02 +0000 Subject: [PATCH] * (plugins/grouphug) thread, don't block (tm) --- data/rbot/plugins/grouphug.rb | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/data/rbot/plugins/grouphug.rb b/data/rbot/plugins/grouphug.rb index 15735b9f..32a6e55e 100644 --- a/data/rbot/plugins/grouphug.rb +++ b/data/rbot/plugins/grouphug.rb @@ -20,16 +20,19 @@ class GrouphugPlugin < Plugin opts.delete(:cache) end - begin - data = @bot.httputil.get("http://grouphug.us/#{path}", opts) - - reg = Regexp.new( '()(.*?)(

)', Regexp::MULTILINE ) - confession = reg.match( data )[4].ircify_html - confession = "no confession ##{params[:num]} found" if confession.empty? and params[:num] - - m.reply confession - rescue - m.reply "failed to connect to grouphug.us" + Thread.start do + begin + data = @bot.httputil.get("http://grouphug.us/#{path}", opts) + + reg = Regexp.new('()(.*?)(

)', + Regexp::MULTILINE) + confession = reg.match( data )[4].ircify_html + confession = "no confession ##{params[:num]} found" if confession.empty? and params[:num] + + m.reply confession + rescue + m.reply "failed to connect to grouphug.us" + end end end end -- 2.39.5