+ if @keywords.delete(key)
+ m.okay
+ else
+ m.reply _("couldn't find keyword %{key}" % { :key => key })
+ end
+ end
+
+ # low-level keyword wipe command for when forget doesn't work
+ def keyword_wipe(m, key)
+ reg = @keywords.registry
+ reg.env.begin(reg) { |t, b|
+ b.delete_if { |k, v|
+ (k == key) && (m.reply "wiping keyword #{key} with stored value #{Marshal.restore(v)}")
+ }
+ t.commit
+ }
+ m.reply "done"
+ end
+
+ # export keywords to factoids file
+ def keyword_factoids_export
+ ar = Array.new
+
+ debug @keywords.keys
+
+ @keywords.each { |k, val|
+ next unless val
+ kw = Keyword.restore(val)
+ ar |= kw.to_factoids(k)
+ }
+
+ # TODO check factoids config
+ # also TODO: runtime export
+ dir = @bot.path 'factoids'
+ fname = File.join(dir,"keyword_factoids.rbot")
+
+ Dir.mkdir(dir) unless FileTest.directory?(dir)
+ Utils.safe_save(fname) do |file|
+ file.puts ar