Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/hipchat/hubot-hipchat
Browse files Browse the repository at this point in the history
* 'master' of git://github.com/hipchat/hubot-hipchat:
  removing circluar loop on reconnect causing stack overflow.
  BOSH server was not actually passed to the connector
  Update rooms processing
  Throw errors if required env vars are unset
  • Loading branch information
cycomachead committed Feb 3, 2016
2 parents 3f383b9 + 1610fee commit 7303388
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/connector.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ module.exports = class Connector extends EventEmitter
@host = options.host
@caps_ver = options.caps_ver or "hubot-hipchat:#{pkg.version}"
@xmppDomain = options.xmppDomain
@bosh = options.bosh

# Multi-User-Conference (rooms) service host. Use when directing stanzas
# to the MUC service.
Expand All @@ -77,6 +78,7 @@ module.exports = class Connector extends EventEmitter
jid: @jid,
password: @password,
host: @host
bosh: @bosh

@jabber.on "error", bind(onStreamError, @)
@jabber.on "online", bind(onOnline, @)
Expand Down Expand Up @@ -135,7 +137,7 @@ module.exports = class Connector extends EventEmitter
stanza.getChild("query").getChildren("item").map (el) ->
x = el.getChild "x", "http://hipchat.com/protocol/muc#room"
# A room
jid: el.attrs.jid
jid: el.attrs.jid.trim()
name: el.attrs.name
id: getInt(x, "id")
topic: getText(x, "topic")
Expand Down Expand Up @@ -500,7 +502,6 @@ onStanza = (stanza) ->

onOffline = ->
@logger.info 'Connection went offline'
@disconnect()

onClose = ->
@logger.info 'Connection was closed'
Expand Down
11 changes: 9 additions & 2 deletions src/hipchat.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,15 @@ class HipChat extends Adapter
, delay * 1000

run: ->
botjid = process.env.HUBOT_HIPCHAT_JID
if not botjid
throw new Error("Environment variable HUBOT_HIPCHAT_JID is required to contain your bot's user JID.")
botpw = process.env.HUBOT_HIPCHAT_PASSWORD
if not botpw
throw new Error("Environment variable HUBOT_HIPCHAT_PASSWORD is required to contain your bot's user password.")
@options =
jid: process.env.HUBOT_HIPCHAT_JID
password: process.env.HUBOT_HIPCHAT_PASSWORD
jid: botjid
password: botpw
token: process.env.HUBOT_HIPCHAT_TOKEN or null
rooms: process.env.HUBOT_HIPCHAT_ROOMS or "All"
rooms_blacklist: process.env.HUBOT_HIPCHAT_ROOMS_BLACKLIST or ""
Expand All @@ -180,6 +186,7 @@ class HipChat extends Adapter
host: @options.host
logger: @logger
xmppDomain: @options.xmppDomain
bosh: @options.bosh
host = if @options.host then @options.host else "hipchat.com"
@logger.info "Connecting HipChat adapter..."

Expand Down

0 comments on commit 7303388

Please sign in to comment.