]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
factoids plugin: short_fact() auxiliary (no metadata)
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 12 Feb 2008 23:01:53 +0000 (00:01 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Tue, 12 Feb 2008 23:01:53 +0000 (00:01 +0100)
data/rbot/plugins/factoids.rb

index 2a75fd52afb92af03d90343083c7749f404a0051..5107422120f81eb6d00c4a02cc233d7e9528feb6 100644 (file)
@@ -271,6 +271,15 @@ class FactoidsPlugin < Plugin
     end
   end
 
+  def short_fact(fact,index=nil,total=@factoids.length)
+    idx = index || @factoids.index(fact)+1
+    _("[%{idx}/%{total}] %{fact}" % {
+      :idx => idx,
+      :total => total,
+      :fact => fact.to_s(:meta => false)
+    })
+  end
+
   def long_fact(fact,index=nil,total=@factoids.length)
     idx = index || @factoids.index(fact)+1
     _("fact #%{idx} of %{total}: %{fact}" % {
@@ -316,10 +325,10 @@ class FactoidsPlugin < Plugin
           end
         end
         known.each { |f|
-          reply << long_fact(f)
+          reply << short_fact(f)
         }
       end
-      m.reply reply.join(" -- "), :split_at => /\s+--\s+/
+      m.reply reply.join(". "), :split_at => /\s+--\s+/
     end
   end