diff --git a/src/rocketchat.coffee b/src/rocketchat.coffee index 6da7ce4ce..9f5ff50e8 100644 --- a/src/rocketchat.coffee +++ b/src/rocketchat.coffee @@ -24,6 +24,9 @@ RespondToDirectMessage = process.env.RESPOND_TO_DM or "false" RespondToEditedMessage = (process.env.RESPOND_TO_EDITED or "false").toLowerCase() SSLEnabled = "false" +if ListenOnAllPublicRooms.toLowerCase() is 'true' + RocketChatRoom = '' + # Custom Response class that adds a sendPrivate and sendDirect method class RocketChatResponse extends Response sendDirect: (strings...) -> @@ -111,6 +114,10 @@ class RocketChatBotAdapter extends Adapter ) # Subscribe to msgs in all rooms .then((res) => + if ListenOnAllPublicRooms.toLowerCase() is 'true' + res = [0] + rooms = ['__my_messages__'] + @robot.logger.info "All rooms joined." subs = [] for result, idx in res diff --git a/src/rocketchat_driver.coffee b/src/rocketchat_driver.coffee index fbe48cc86..6d9b546d7 100644 --- a/src/rocketchat_driver.coffee +++ b/src/rocketchat_driver.coffee @@ -7,9 +7,9 @@ LRU = require('lru-cache') # TODO: need to grab these values from process.env[] -_msgsubtopic = 'stream-messages' # 'messages' +_msgsubtopic = 'stream-room-messages' # 'messages' _msgsublimit = 10 # this is not actually used right now -_messageCollection = 'stream-messages' +_messageCollection = 'stream-room-messages' # room id cache _roomCacheSize = parseInt(process.env.ROOM_ID_CACHE_SIZE) || 10 @@ -97,7 +97,7 @@ class RocketChatDriver # data.roomid # return promise @logger.info "Preparing Meteor Subscriptions.." - msgsub = @asteroid.subscribe _msgsubtopic, data.roomid, _msgsublimit + msgsub = @asteroid.subscribe _msgsubtopic, data.roomid, true @logger.info "Subscribing to Room: #{data.roomid}" return msgsub.ready @@ -117,7 +117,7 @@ class RocketChatDriver # console.log('changed:', JSON.stringify(changedMsg, null, 2)); if changedMsg.args? @logger.info "Message received with ID " + id - receiveMessageCallback changedMsg.args[1] + receiveMessageCallback changedMsg.args[0] callMethod: (name, args = []) => @logger.info "Calling: #{name}, #{args.join(', ')}"