diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-11-04 12:18:27 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-11-04 12:18:27 +0000 |
commit | 60682184a5679d1da2fc94b58696a10f4792705c (patch) | |
tree | dcaab9f3859c42d555690c18d81976148215fc1f | |
parent | e232332ed4f23d757dfd1421a4d3c4896e45a14a (diff) |
factoids plugin: tell fact metadata, if present
-rw-r--r-- | data/rbot/plugins/factoids.rb | 20 |
1 files changed, 18 insertions, 2 deletions
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 |