From 60682184a5679d1da2fc94b58696a10f4792705c Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 4 Nov 2007 12:18:27 +0000 Subject: factoids plugin: tell fact metadata, if present --- data/rbot/plugins/factoids.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/factoids.rb b/data/rbot/plugins/factoids.rb index 99d6ba75..96bb729a 100644 --- a/data/rbot/plugins/factoids.rb +++ b/data/rbot/plugins/factoids.rb @@ -31,6 +31,7 @@ class FactoidsPlugin < Plugin def to_hsh return @hash end + alias :to_hash :to_hsh end class FactoidList < ArrayOf @@ -179,10 +180,25 @@ class FactoidsPlugin < Plugin fact = known.pick_one idx = @factoids.index(fact)+1 end - m.reply _("fact %{idx}/%{total}: %{fact}" % { + meta = nil + metadata = [] + if fact[:who] + metadata << _("from %{who}" % fact.to_hash) + end + if fact[:when] + metadata << _("on %{when}" % fact.to_hash) + end + if fact[:where] + metadata << _("in %{where}" % fact.to_hash) + end + unless metadata.empty? + meta = _(" [learnt %{data}]" % {:data => metadata.join(" ")}) + end + m.reply _("fact %{idx}/%{total}: %{fact}%{meta}" % { :idx => idx, :total => total, - :fact => fact + :fact => fact, + :meta => meta }) end -- cgit v1.2.3