-# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/)
-# (c) 2005 Mark Kretschmann <markey@web.de>
-# Licensed under GPL V2.
-
-require "net/http"
-
+#-- vim:sw=2:et
+#++
+#
+# :title: Grouphug Plugin for rbot
+#
+# Author:: Mark Kretschmann <markey@web.de>
+# Copyright:: (C) 2005 Mark Kretschmann
+# License:: GPL v2
class GrouphugPlugin < Plugin
def help( plugin, topic="" )
end
def confess(m, params)
+ opts = { :cache => false }
path = "random"
- path = "confessions/#{params[:num]}" if params[:num]
+ if params[:num]
+ path = "confessions/#{params[:num]}"
+ opts.delete(:cache)
+ end
+
begin
- data = bot.httputil.get_cached(URI.parse("http://grouphug.us/#{path}"))
+ data = @bot.httputil.get("http://grouphug.us/#{path}", opts)
- reg = Regexp.new( '(<td class="conf-text")(.*?)(<p>)(.*?)(</p>)', Regexp::MULTILINE )
+ reg = Regexp.new('(<td class="conf-text")(.*?)(<p>)(.*?)(</p>)',
+ Regexp::MULTILINE)
confession = reg.match( data )[4].ircify_html
confession = "no confession ##{params[:num]} found" if confession.empty? and params[:num]
plugin = GrouphugPlugin.new
-plugin.map "grouphug [:num]", :action => :confess, :requirements => { :num => /\d+/ }
-plugin.map "confess [:num]", :action => :confess, :requirements => { :num => /\d+/ }
+plugin.map "grouphug [:num]",
+ :thread => true, :action => :confess, :requirements => { :num => /\d+/ }
+plugin.map "confess [:num]",
+ :thread => true, :action => :confess, :requirements => { :num => /\d+/ }