]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/grouphug.rb
keywords plugin: keyword wipe command to remove unforgettable keywords
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / grouphug.rb
index 75093665067f7036d237e9f2d77ca01467d3adf0..bf246b4c7f7fa23b3911dbf4169b4c01d59071a5 100644 (file)
@@ -13,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( '(<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]
 
@@ -32,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+/ }