 #   therealklanni
 
 factoids =
-  set: (key, value, who) ->
+  set: (key, value, who, resolveAlias) ->
     key = key.trim()
     value = value.trim()
-    fact = factoids.get key
+    fact = factoids.get key, resolveAlias
 
     if typeof fact is 'object'
       fact.history ?= []

      to ?= msg.message.user.name
      msg.send "#{to.trim()}: #{fact.value}"

  robot.respond /learn (.{3,}) = (.+)/i, (msg) ->
    msg.reply factoids.set msg.match[1], msg.match[2], msg.message.user.name

  robot.respond /learn (.{3,}) =~ s\/(.+)\/(.+)\/(.*)/i, (msg) ->

    who = msg.message.user.name
    alias = msg.match[1]
    target = msg.match[2]
    msg.reply "OK, aliased #{alias} to #{target}" if factoids.set msg.match[1], "@#{msg.match[2]}", msg.message.user.name, false

  robot.respond /drop (.{3,})/i, (msg) ->
    user = msg.envelope.user
