     # Close response
     res.writeHead 204, { 'Content-Length': 0 }
     res.end()
-
-
-  get_reviewers = (resp) ->
-    if resp.pullrequest.reviewers.length > 0
-      reviewers = ''
-      for reviewer in resp.pullrequest.reviewers
-        reviewers += " #{reviewer.display_name}"
-    else
-      reviewers = ' no one in particular'
-
-    return reviewers
-
-  # Consolidate redundant formatting with branch_action func
-
-  if robot.adapterName is 'slack'
-
-    branch_action = (resp, action_name, cached_vars, color) ->
-      fields = []
-      fields.push
-        title: cached_vars.title
-        value: resp.pullrequest.reason
-        short: true
-      fields.push
-        title: "#{cached_vars.repo_name} (#{cached_vars.source_branch})"
-        value: cached_vars.pr_link
-        short: true
-
-      payload =
-        text: "Pull Request #{action_name} by #{cached_vars.actor}"
-        fallback: "#{cached_vars.actor} *#{action_name}* pull request \"#{cached_vars.title}\"."
-        pretext: ''
-        color: color
-        mrkdwn_in: ["text", "title", "fallback", "fields"]
-        fields: fields
-
-      return payload
-

  pullRequestUnapproved: ->
    "A pull request on `#{@repo_name}` has been unapproved by #{@actor}\n#{@pr_link}"

module.exports = (robot) ->
  robot.router.post '/hubot/bitbucket-pr', (req, res) ->
    resp = req.body

    # https://confluence.atlassian.com/bitbucket/event-payloads-740262817.html#EventPayloads-HTTPHeaders
    type = req.headers['x-event-key']

    # Fallback to default Pull request room
    room = req.query.room ? DEFAULT_ROOM

    # Slack special formatting
    if robot.adapterName is 'slack'
      event = new SlackPullRequestEvent(robot, resp, type)

      msg =
        message:
          reply_to: room
          room: room

      msg.content = event.getMessage()
      robot.emit 'slack-attachment', msg

    # For hubot adapters that are not Slack
