From 1fa68bb86705b0e1e70d9d655bbfd8e1e13eb093 Mon Sep 17 00:00:00 2001 From: Casey Link Date: Fri, 20 Jun 2008 09:56:45 -0400 Subject: grouphug plugin: tweak regex so it captures confessions with newlines properly --- data/rbot/plugins/grouphug.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/data/rbot/plugins/grouphug.rb b/data/rbot/plugins/grouphug.rb index 4e7eaf5d..f08f5753 100644 --- a/data/rbot/plugins/grouphug.rb +++ b/data/rbot/plugins/grouphug.rb @@ -10,6 +10,7 @@ # License:: GPL v2 class GrouphugPlugin < Plugin + REG = Regexp.new('
\s*

(.*?)

\s+
', Regexp::MULTILINE) def initialize super @confessions = Array.new @@ -29,16 +30,14 @@ class GrouphugPlugin < Plugin opts.delete(:cache) data = @bot.httputil.get("http://grouphug.us/#{path}", opts) - reg = Regexp.new('
.*?

(.*?)

', Regexp::MULTILINE) - res = data.scan(reg) + res = data.scan(REG) confession = res[0][0].ircify_html confession = "no confession ##{params[:num]} found" if confession.empty? and params[:num] m.reply confession else # Cache random confessions if @confessions.empty? data = @bot.httputil.get("http://grouphug.us/#{path}", opts) - reg = Regexp.new('
.*?

(.*?)

', Regexp::MULTILINE) - res = data.scan(reg) + res = data.scan(REG) res.each do |quote| @confessions << quote[0].ircify_html end -- cgit v1.2.3