 nameOf = (account) -> account?.name || account?.email || "Gerrit"
 
 module.exports = (robot) ->
-  gerrit = url.parse process.env.HUBOT_GERRIT_SSH_URL || ""
+  gerrit = url.parse sshUrl
   gerrit.port = 22 unless gerrit.port
   if gerrit.protocol != "ssh:" || gerrit.hostname == ""
     robot.logger.error "Gerrit commands inactive because HUBOT_GERRIT_SSH_URL=#{gerrit.href} is not a valid SSH URL"
   else
-    eventStreamMe robot, gerrit
+    eventStreamMe robot, gerrit unless eventStreamRooms == "disabled"
     robot.respond /gerrit (?:search|query)(?: me)? (.+)/i, searchMe robot, gerrit
     robot.respond /gerrit (ignore|report)(?: me)? events for (.+)/i, ignoreOrReportEventsMe robot, gerrit
 

# hubot gerrit ignore events for <project> - Don't spam about events happening for the specified project.
# hubot gerrit report events for <project> - Reset Hubot to spam about events happening for the specified project.
#

cp = require "child_process"
url = require "url"

    if msg == null
      robot.logger.info "Gerrit stream-events: Unrecognized event #{data}"
    else if msg && isWanted projectFor json
      # Bug in messageRoom? Doesn't work with multiple rooms
      #robot.messageRoom room, "Gerrit: #{msg}" for room in robotRooms robot
      robot.send room: room, "Gerrit: #{msg}" for room in robotRooms robot

robotRooms = (robot) ->
  roomlists =
    if eventStreamRooms
      [ eventStreamRooms ]
    else
      v for k,v of process.env when /^HUBOT_.+_ROOMS/i.exec(k) isnt null
  robot.logger.error "Gerrit stream-events: Unable to determine the list of rooms" if roomlists.length == 0
  r for r in (roomlists[0] || "").split "," when r isnt ""
