 #   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 ?= []

    factoids.data[key.toLowerCase()] = fact
    "OK, #{key} is now #{value}"

  get: (key) ->
    fact = factoids.data?[key.toLowerCase()]
    alias = fact?.value?.match /^@([^@].+)$/i
    if alias?
      fact = factoids.get alias[1]
    fact


      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) ->
