 
     bot.onConnect =>
       console.log "Connected to HipChat"
-      @get "/v1/rooms/list", (err, response)->
-        if response
-          response.rooms.forEach (room)->
-            bot.join room.xmpp_jid
-        else
-          console.log "Can't list rooms: #{err}"
+      if @options.rooms == "@All"
+        @get "/v1/rooms/list", (err, response)->
+          if response
+            response.rooms.forEach (room)->
+              console.log "Joining #{room.xmpp_jid}"
+              bot.join room.xmpp_jid
+          else
+            console.log "Can't list rooms: #{err}"
+      else
+        @options.rooms.split(',').forEach (room_id)->
+          console.log "Joining #{room_id}"
+          bot.join room_id
       @get "/v1/users/list", (err, response)->
         if response
           response.users.forEach (user)->

    @options =
      token:    process.env.HUBOT_HIPCHAT_TOKEN
      jid:      process.env.HUBOT_HIPCHAT_JID
      name:     process.env.HUBOT_HIPCHAT_NAME || "Hubot, I"
      password: process.env.HUBOT_HIPCHAT_PASSWORD

    console.log "Options:", @options
    bot = new Wobot(jid: @options.jid, name: @options.name, password: @options.password)

          console.log "Can't list rooms: #{err}"
    bot.onError (message, stanza)->
      console.log "Received error from HipChat:", message, stanza
    bot.onMessage RegExp('@'+@name,'i'), (channel, from, message)->
      author = self.userForName(from)
      author.room = channel
      console.log "#{from}@#{channel}: #{message}"
      hubot_msg=message.replace(RegExp("@#{self.name}",'i'),"#{self.name}: ")
      self.receive new Robot.Message(author, hubot_msg)
    bot.onPrivateMessage (from, message)=>
      author = self.userForId(from.match(/_(\d+)@/)[1])
      author.jid = from
      self.receive new Robot.Message(author, "#{self.name}: #{message}")
    bot.connect()

    @bot = bot
