summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/grouphug.rb7
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