diff --git a/src/bot.coffee b/src/bot.coffee index fc2885ae..f99096b1 100644 --- a/src/bot.coffee +++ b/src/bot.coffee @@ -36,6 +36,12 @@ class SlackBot extends Adapter constructor: (@robot, @options) -> @client = new SlackClient(@options, @robot) + ### + Slackbot loads full user list on the first brain load + QUESTION: why do brain adapters trigger a brain 'loaded' event each time a key + is set? + ### + setIsLoaded: (@isLoaded) -> ### Slackbot initialization @@ -55,8 +61,12 @@ class SlackBot extends Adapter @client.on 'user_change', @userChange @client.web.users.list @loadUsers + @robot.brain.on 'loaded', () => - @client.web.users.list @loadUsers + if not @isLoaded + @client.web.users.list @loadUsers + this.setIsLoaded(true) + # Start logging in @client.connect() diff --git a/src/client.coffee b/src/client.coffee index 729354fc..86611c46 100644 --- a/src/client.coffee +++ b/src/client.coffee @@ -31,6 +31,7 @@ class SlackClient Open connection to the Slack RTM API ### connect: -> + # QUESTION: why do we throw away the login data? @rtm.login()