4 # :title: Grouphug Plugin for rbot
6 # Author:: Mark Kretschmann <markey@web.de>
7 # Copyright:: (C) 2005 Mark Kretschmann
10 class GrouphugPlugin < Plugin
11 def help( plugin, topic="" )
12 return "Grouphug plugin. Confess! Usage: 'confess' for random confession, 'confess <number>' for specific one."
15 def confess(m, params)
16 opts = { :cache => false }
19 path = "confessions/#{params[:num]}"
24 data = @bot.httputil.get("http://grouphug.us/#{path}", opts)
26 reg = Regexp.new( '(<td class="conf-text")(.*?)(<p>)(.*?)(</p>)', Regexp::MULTILINE )
27 confession = reg.match( data )[4].ircify_html
28 confession = "no confession ##{params[:num]} found" if confession.empty? and params[:num]
32 m.reply "failed to connect to grouphug.us"
38 plugin = GrouphugPlugin.new
40 plugin.map "grouphug [:num]", :action => :confess, :requirements => { :num => /\d+/ }
41 plugin.map "confess [:num]", :action => :confess, :requirements => { :num => /\d+/ }