robot.presenceChange didn't work after configuring all the scripts
Saticppro opened this issue · 2 comments
Description
Describe your issue here.
What type of issue is this? (place an x
in one of the [ ]
)
- [ x] bug
- enhancement (feature request)
- question
- documentation related
- testing related
- discussion
Requirements (place an x
in each of the [ ]
)
- [x ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
- [ x] I've read and agree to the Code of Conduct.
- [x ] I've searched for any related issues and avoided creating a duplicate issue.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
hubot-slack version: 4.7.1
node version: 0.10.x
OS version(s):
Steps to reproduce:
Expected result:
to display the user status when he changes the status in slack
What you expected to happen
Actual result:
What actually happened
a blank console wihout any result
Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.
Please look into the issue, I really need this solution as early as possible
I'm sorry that you didn't get any response at the time. I know this may be too late but let me share a code snippet that works for you.
To receive presence_change
events over RTM, it is required to send presense_sujb
requests in advance. Refer to https://api.slack.com/events/presence_sub for details about presence_sub
.
If your brain
datastore already has a list of users when starting a Hubot app, it automatically calls presenseSub()
method for you. Otherwise, you can manually send such requests as the following code does with a keyword "test".
module.exports = (robot, options) ->
robot.hear /test/i, (res) ->
robot.adapter.presenceSub()
robot.presenceChange (res) ->
# res.message is a PresenceMessage instance that represents the presence change Hubot just heard
names = (user.name for user in res.message.users).join ", "
message = if res.message.presence is "away" then "Bye bye #{names}" else "Glad you are back #{names}"
robot.logger.debug message
I hope this is helpful to you despite the delay and allow me to close this now. Please feel free to write in or reopen this if you have something further to ask/clarify regarding this.