summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-11-04 14:02:36 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-11-04 14:02:36 +0000
commit1a0dba4dec4b76aa3de34bdce4374c0ef11760ea (patch)
tree580794ab5ef67286b70ebfd9935fb9891481bd7c /data
parenteb9c71440b99756df6b11e32c4ac58ab6e66e1bd (diff)
factoids plugin: ensure that edited metadata is properly saved, and check for parseable dates
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/factoids.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/data/rbot/plugins/factoids.rb b/data/rbot/plugins/factoids.rb
index adadba31..64e4514e 100644
--- a/data/rbot/plugins/factoids.rb
+++ b/data/rbot/plugins/factoids.rb
@@ -219,14 +219,21 @@ class FactoidsPlugin < Plugin
begin
if params[:who]
who = params[:who].to_s.sub(/^me$/, m.source.fullform)
- debug who
fact[:who] = who
+ @changed = true
end
if params[:when]
- fact[:when] = Time.parse(params[:when].to_s)
+ dstr = params[:when].to_s
+ begin
+ fact[:when] = Time.parse(dstr, "")
+ @changed = true
+ rescue
+ raise ArgumentError, _("not a date '%{dstr}'" % { :dstr => dstr })
+ end
end
if params[:where]
fact[:where] = params[:where].to_s
+ @changed = true
end
rescue Exception
m.reply _("couldn't change learn data for fact %{fact}: %{err}" % {
@@ -249,6 +256,7 @@ 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 :learn from *who', :action => :edit_fact, :requirements => { :learn => /^((?:is|was)\s+)?learn(ed|t)$/, :index => /^#?\d+$/ }, :auth_path => 'edit'
plugin.map 'fact :index :learn on *when', :action => :edit_fact, :requirements => { :learn => /^((?:is|was)\s+)?learn(ed|t)$/, :index => /^#?\d+$/ }, :auth_path => 'edit'
plugin.map 'fact :index :learn in *where', :action => :edit_fact, :requirements => { :learn => /^((?:is|was)\s+)?learn(ed|t)$/, :index => /^#?\d+$/ }, :auth_path => 'edit'