 #   None
 #
 # Configuration:
-#   None
+#   HUBOT_GREETING_FFA - If set, any user can set any other user's greeting.
 #
 # Commands:
 #   hubot greet <name> - Test out <name>'s current greeting; can be "me" or "yourself".


  robot.respond /forget (\S+)('s)? greetings$/i, (msg) ->
    target = chooseTarget msg, msg.match[1]
    withGreetings target, (greetings) ->
      msg.reply "Forgetting #{greetings.length} greetings."
      []

    # Set as some user, whether in the room or not
    return match

  verifyPermission = (msg, target) ->
    return true if freeForAll or msg.message.user.name is target
    user = robot.brain.userForName target
    if user? and user.roles? and GREETING_ROLE in user.roles
      true
    else
      msg.reply "I can't do that, you're not a #{GREETING_ROLE}!"
      false

  robot.respond /greet (\S+) with (.+)/i, (msg) ->
    target = chooseTarget msg, msg.match[1]
    return unless verifyPermission msg, target

    greeting = msg.match[2]
    withGreetings target, (greetings) ->
      greetings.push greeting
