mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
28 lines
1.1 KiB
CoffeeScript
28 lines
1.1 KiB
CoffeeScript
config = require '../server_config'
|
|
request = require 'request'
|
|
log = require 'winston'
|
|
|
|
module.exports.sendHipChatMessage = sendHipChatMessage = (message) ->
|
|
return unless key = config.hipchatAPIKey
|
|
roomID = 254598
|
|
form =
|
|
color: 'yellow'
|
|
notify: false
|
|
message: message
|
|
messageFormat: 'html'
|
|
url = "https://api.hipchat.com/v2/room/#{roomID}/notification?auth_token=#{key}"
|
|
request.post {uri: url, json: form}, (err, res, body) ->
|
|
return log.error 'Error sending HipChat patch request:', err or body if err or /error/i.test body
|
|
#log.info "Got HipChat patch response:", body
|
|
|
|
module.exports.sendTowerHipChatMessage = sendTowerHipChatMessage = (message) ->
|
|
return unless key = config.hipchatTowerAPIKey
|
|
roomID = 318356
|
|
form =
|
|
color: 'red'
|
|
notify: true
|
|
message: message
|
|
messageFormat: 'html'
|
|
url = "https://api.hipchat.com/v2/room/#{roomID}/notification?auth_token=#{key}"
|
|
request.post {uri: url, json: form}, (err, res, body) ->
|
|
return log.error 'Error sending HipChat Tower message:', err or body if err or /error/i.test body
|