diff options
author | Casey Link <unnamedrambler@gmail.com> | 2008-06-20 09:56:45 -0400 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-06-20 16:06:32 +0200 |
commit | 1fa68bb86705b0e1e70d9d655bbfd8e1e13eb093 (patch) | |
tree | dd1e06feefc0d62d0eb3c251097899305db200d5 /data | |
parent | c53a13e0be7ad9f569bee2ce450b875f5abe7de5 (diff) |
grouphug plugin: tweak regex so it captures confessions with newlines properly
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/grouphug.rb | 7 |
1 files 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('<div class="content">\s*<p>(.*?)</p>\s+</div>', 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('<div class="content">.*?<p>(.*?)</p>', 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('<div class="content">.*?<p>(.*?)</p>', Regexp::MULTILINE) - res = data.scan(reg) + res = data.scan(REG) res.each do |quote| @confessions << quote[0].ircify_html end |