-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
robot.enter and robot.leave doesn't work #296
Comments
Hello, would love to help out, but I'm afraid I need more details on your problem. Can you post a more detailed chunk of code that illustrates the problem you are having? |
Having the same problem, pulled code directly from samples. Never kicks off. module.exports = (robot) -> module.exports = (robot) -> |
the adapter seem to be hooked up correctly to |
I'm testing Hubot with Slack now and I can get the channel |
@JoniSykes thanks for the feedback! you inspired me to try reproducing the problem and even before getting there, i think i found it. the current implementation relies on RTM we need to update the implementation of the adapter to listen for and handle those events to generate the |
👍 module.exports = (robot) ->
robot.enter (msg) ->
general = robot.adapter.client.rtm.dataStore.getChannelByName '#general'
if msg.message.room == general.id
robot.send {room: msg.message.user.id}, "Hi, *#{msg.message.user.name}*! :wave:" I tried with the same hubot/hubot-slack versions, but nothing happens. |
@alagos thanks for the data point. the best i can do to explain that is to say that the older event types are no longer guaranteed, so its possible that the differences in your workspaces are responsible for the different behavior. |
for @alagos and anyone else that comes across this issue, i wanted to update the code sample shared above, since the first, make sure you install the latest
next, follow the instructions in the docs for sending a message to a different channel, except listen for the enter event. once the above code is merged, this should work consistently for all users who enter the channel. {WebClient} = require "@slack/client"
module.exports = (robot) ->
# create a dedicated Web API client
web = new WebClient robot.adapter.options.token
# use the Web API client to get a list of all channels
web.channels.list()
.then (api_response) ->
# Search the list for the channels for #general
conversation = api_response.channels.find (channel) -> channel.name is "general"
if conversation
conversation.id
else
throw new Error('general room not found')
.then (conversationId) ->
# Now that we have the conversation ID for #general, start listening for users who join
robot.enter (res) ->
if res.message.room is conversationId
# Create a DM conversation with the user who just joined
web.im.open({ user: res.message.user.id })
.then (create_response) ->
# In the new DM conversation, send them a welcome message.
res.send { room: create_response.channel.id }, "Hi, *<@#{res.message.user.id}>, :wave:"
.catch (error) ->
@robot.logger.error "Could not create an IM with user #{res.message.user.id}: #{error.message}"
.catch (error) ->
@robot.logger.error error.message |
I build hubot-slack in 3.4.2
I write it on example.coffee , but isn't work .
It's mean tigger enter on click bot's use?
It's mean tigger leave on click other use?
`module.exports = (robot) ->
The text was updated successfully, but these errors were encountered: