]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
factoids plugin: output fact numbers prefixed by a pound sign (#), and accept it...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 4 Nov 2007 12:19:11 +0000 (12:19 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 4 Nov 2007 12:19:11 +0000 (12:19 +0000)
data/rbot/plugins/factoids.rb

index 96bb729a6283a43ef76309f50c8cc99607efde78..59f1a06bbda3a5b253a39b258c0b6f145938d85c 100644 (file)
@@ -155,7 +155,7 @@ class FactoidsPlugin < Plugin
     idx = 0
     total = @factoids.length
     if params[:index]
-      idx = params[:index].to_i
+      idx = params[:index].scan(/\d+/).first.to_i
       if idx <= 0 or idx > total
         m.reply _("please select a fact number between 1 and %{total}" % { :total => total })
         return
@@ -194,7 +194,7 @@ class FactoidsPlugin < Plugin
     unless metadata.empty?
       meta = _(" [learnt %{data}]" % {:data => metadata.join(" ")})
     end
-    m.reply _("fact %{idx}/%{total}: %{fact}%{meta}" % {
+    m.reply _("fact #%{idx} of %{total}: %{fact}%{meta}" % {
       :idx => idx,
       :total => total,
       :fact => fact,
@@ -212,4 +212,4 @@ plugin.map 'learn that *stuff'
 plugin.map 'forget that *stuff', :auth_path => 'edit'
 plugin.map 'facts [about *words]'
 plugin.map 'fact [about *words]'
-plugin.map 'fact :index', :requirements => { :index => /\d+/ }
+plugin.map 'fact :index', :requirements => { :index => /#?\d+/ }