<commit_before>NotificationPlugin = require "../../notification-plugin"
Handlebars = require 'handlebars'

class Hipchat extends NotificationPlugin
  API_BASE_URL = "https://api.hipchat.com/"

  getApiUrl = (config, path) ->
    if config.host?
      host = if /\/$/.test(config.host) then config.host else config.host + "/"
    else
      host = API_BASE_URL

    "#{host}#{path}?auth_token=#{config.authToken}"

  @receiveEvent: (config, event, callback) ->
    # Build the message
    if event.error
      details =
        title: "#{event.trigger.message} in #{event.error.releaseStage}"
        error_string: (event.error.exceptionClass + (if event.error.message then ": #{event.error.message}")).truncate(85)
        stack_trace_line: event.error.stacktrace && @firstStacktraceLine(event.error.stacktrace)
        project: event.project
        error: event.error
        spiking: event.trigger.type == 'projectSpiking'
        rate: event.trigger.rate
        comment: event.comment
        user: event.user

      if details.comment?.message
        details.comment.message = details.comment.message.truncate(80)

    else<commit_msg>Fix hipchat<commit_after>NotificationPlugin = require "../../notification-plugin"
Handlebars = require 'handlebars'

class Hipchat extends NotificationPlugin
  API_BASE_URL = "https://api.hipchat.com/"

  getApiUrl = (config, path) ->
    if config.host? && config.host != ""
      host = if /\/$/.test(config.host) then config.host else config.host + "/"
    else
      host = API_BASE_URL

    "#{host}#{path}?auth_token=#{config.authToken}"

  @receiveEvent: (config, event, callback) ->
    # Build the message
    if event.error
      details =
        title: "#{event.trigger.message} in #{event.error.releaseStage}"
        error_string: (event.error.exceptionClass + (if event.error.message then ": #{event.error.message}")).truncate(85)
        stack_trace_line: event.error.stacktrace && @firstStacktraceLine(event.error.stacktrace)
        project: event.project
        error: event.error
        spiking: event.trigger.type == 'projectSpiking'
        rate: event.trigger.rate
        comment: event.comment
        user: event.user

      if details.comment?.message
        details.comment.message = details.comment.message.truncate(80)

    else
{'fraction_non_alphanumeric': 0.13156752062527138, 'fraction_numerical': 0.0034737299174989146, 'mean_word_length': 3.0492091388400704, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6317080', 'n_tokens_mistral': 687, 'n_tokens_neox': 668, 'n_words': 139}