1 # Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/)
2 # (c) 2005 Mark Kretschmann <markey@web.de>
3 # Licensed under GPL V2.
8 class GrouphugPlugin < Plugin
9 def help( plugin, topic="" )
10 "Grouphug plugin. Confess! Usage: 'confess' for random confession, 'confess <number>' for specific one."
15 path = "/confessions/#{m.params()}" if m.params()
17 data = bot.httputil.get(URI.parse("http://grouphug.us/#{path}"))
19 reg = Regexp.new( '(<td class="conf-text")(.*?)(<p>)(.*?)(</p>)', Regexp::MULTILINE )
20 confession = reg.match( data )[4]
21 confession.gsub!( /<.*?>/, "" ) # Remove html tags
22 confession.gsub!( "\t", "" ) # Remove tab characters
24 @bot.say(m.replyto, confession)
26 m.reply "failed to connect to grouphug.us"
32 plugin = GrouphugPlugin.new
34 plugin.register("grouphug")
35 plugin.register("confess")