summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/factoids.rb
diff options
context:
space:
mode:
Diffstat (limited to 'data/rbot/plugins/factoids.rb')
-rw-r--r--data/rbot/plugins/factoids.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/data/rbot/plugins/factoids.rb b/data/rbot/plugins/factoids.rb
index eee1dfaa..d9966fa8 100644
--- a/data/rbot/plugins/factoids.rb
+++ b/data/rbot/plugins/factoids.rb
@@ -149,9 +149,35 @@ class FactoidsPlugin < Plugin
end
end
+ def fact(m, params)
+ known = nil
+ if params[:words].empty?
+ if @factoids.empty?
+ m.reply _("I know nothing")
+ return
+ end
+ known = @factoids
+ else
+ rx = Regexp.new(params[:words].to_s, true)
+ known = @factoids.grep(rx)
+ if known.empty?
+ m.reply _("I know nothing about %{words}" % params)
+ return
+ end
+ end
+ fact = known.pick_one
+ idx = @factoids.index(fact)+1
+ m.reply _("fact %{idx}/%{total}: %{fact}" % {
+ :idx => idx,
+ :total => @factoids.length,
+ :fact => fact
+ })
+ end
+
end
plugin = FactoidsPlugin.new
plugin.map 'learn that *stuff'
plugin.map 'forget that *stuff'
plugin.map 'facts [about *words]'
+plugin.map 'fact [about *words]'