X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=data%2Frbot%2Fplugins%2Fgrouphug.rb;h=bf246b4c7f7fa23b3911dbf4169b4c01d59071a5;hb=de9ddb8a7eb436c0cb8db81289373dc169f484ba;hp=87a7e32c1895e24c7ac8e173a16619cda2d7a99c;hpb=d29df50ddaf32536b105decefb135a0b86ee937f;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/grouphug.rb b/data/rbot/plugins/grouphug.rb index 87a7e32c..bf246b4c 100644 --- a/data/rbot/plugins/grouphug.rb +++ b/data/rbot/plugins/grouphug.rb @@ -1,9 +1,11 @@ -# Plugin for the Ruby IRC bot (http://linuxbrit.co.uk/rbot/) -# (c) 2005 Mark Kretschmann -# Licensed under GPL V2. - -require "net/http" - +#-- vim:sw=2:et +#++ +# +# :title: Grouphug Plugin for rbot +# +# Author:: Mark Kretschmann +# Copyright:: (C) 2005 Mark Kretschmann +# License:: GPL v2 class GrouphugPlugin < Plugin def help( plugin, topic="" ) @@ -11,12 +13,18 @@ class GrouphugPlugin < Plugin 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( '()(.*?)(

)', Regexp::MULTILINE ) + reg = Regexp.new('()(.*?)(

)', + Regexp::MULTILINE) confession = reg.match( data )[4].ircify_html confession = "no confession ##{params[:num]} found" if confession.empty? and params[:num] @@ -30,6 +38,8 @@ end 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+/ }