# Description
#   Message Team Leads when a attention-everyone is added to a PR
TeamLeadsHelper = require '../TeamLeadsHelper'
PullRequest = require '../PullRequest'

module.exports = (robot) ->

  teamLeadsHelper = new TeamLeadsHelper robot
  
  robot.on 'github.pull_request.labeled', (pullRequest) ->

   if pullRequest.label.name == process.env.HUBOT_ATTENTION_EVERYONE_LABEL
      attentionEveryone = new PullRequest(pullRequest)
      message = "The attention-everyone label was added to " +
      "PR(#{attentionEveryone.number}) #{attentionEveryone.url}\n" +
      "All Team Leads need to review this Pull Request"
      teamLeadsHelper.messageTeamLeads(message)
