From a7b978fd0a49e311307af6dfcf0552446d65f7fc Mon Sep 17 00:00:00 2001 From: Robert Bergman Date: Mon, 27 Apr 2015 08:48:32 -0600 Subject: [PATCH 1/4] Throw errors if required env vars are unset The hipchat adapter requires user a jid and password pair for the bot to login with. If unset, emit useful errors. --- src/hipchat.coffee | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hipchat.coffee b/src/hipchat.coffee index b8cbb38..a305e9b 100644 --- a/src/hipchat.coffee +++ b/src/hipchat.coffee @@ -68,9 +68,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 "" From 6264f892bfeed6df552732ab0bf5d96dacad8a4f Mon Sep 17 00:00:00 2001 From: Brad Wedell Date: Fri, 10 Jul 2015 16:23:43 -0600 Subject: [PATCH 2/4] Update rooms processing If a user passing a comma separated HUBOT_HIPCHAT_ROOMS list included a space in the room names (like many people probably do), then the system fails when trying to join the second room because the space is being included in the name. This ensures that the jid it tries to use is using the "trimmed" version with beginning and ending whitespace removed. --- src/connector.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connector.coffee b/src/connector.coffee index 091b4dd..94b837a 100644 --- a/src/connector.coffee +++ b/src/connector.coffee @@ -137,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") From 731d3a6d1910f4c5bafd442fa154e5614d18b089 Mon Sep 17 00:00:00 2001 From: Alex Kuiper Date: Mon, 12 Oct 2015 14:30:51 +0200 Subject: [PATCH 3/4] BOSH server was not actually passed to the connector Change-Id: If1089a78ddec4956a9f37bc5f0569bfe24a9ad0a --- src/connector.coffee | 2 ++ src/hipchat.coffee | 1 + 2 files changed, 3 insertions(+) diff --git a/src/connector.coffee b/src/connector.coffee index 091b4dd..2010cd1 100644 --- a/src/connector.coffee +++ b/src/connector.coffee @@ -66,6 +66,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. @@ -79,6 +80,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, @) diff --git a/src/hipchat.coffee b/src/hipchat.coffee index d114d6c..39555d9 100644 --- a/src/hipchat.coffee +++ b/src/hipchat.coffee @@ -90,6 +90,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..." From 1dbf8d4e911673d2ec566452f4b1fc1e15b7edd4 Mon Sep 17 00:00:00 2001 From: Aaron Blythe Date: Tue, 22 Dec 2015 17:28:55 -0600 Subject: [PATCH 4/4] removing circluar loop on reconnect causing stack overflow. --- src/connector.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/connector.coffee b/src/connector.coffee index 326f90f..60a48f6 100644 --- a/src/connector.coffee +++ b/src/connector.coffee @@ -500,7 +500,6 @@ onStanza = (stanza) -> onOffline = -> @logger.info 'Connection went offline' - @disconnect() onClose = -> @logger.info 'Connection was closed'