-
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
Add callback support to bot::{reply,send} #440
Conversation
This CI is failing since one of the Slack node client dependencies, have published a version that uses ES6 |
sent_messages = [] | ||
for message in messages | ||
if message isnt '' | ||
sent_messages.push @client.send(envelope, message) | ||
Promise.all(messages).then(callback.bind(null, null), callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this supposed to be Promise.all(sent_messages)...
?
sent_messages = [] | ||
for message in messages | ||
if message isnt '' | ||
message = "<@#{envelope.user.id}>: #{message}" unless envelope.room[0] is 'D' | ||
@robot.logger.debug "Sending to #{envelope.room}: #{message}" | ||
sent_messages.push @client.send(envelope, message) | ||
Promise.all(messages).then(callback.bind(null, null), callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto to above
@alFReD-NSH thanks for the contribution! i think its a good idea and i'd like to see it merged. i think something strange is going on with github's "update branch" capability, because i don't see the merge commit being added to this PR after i click that button. the travis build is running against SHA 2428a1190468cdd5ac2ab7c3a342efa0bcdcf20b, which is a 404 in the repo, so the coverage data is not being reported correctly. can you give maintainers permission to update this PR so i can see if i can trigger the right reporting? |
i still think the idea of this PR is valid, but the code that it touches has changed and is being refactored heavily in #465. i'm happy to land this if you can implement the changes on top of that. |
tracking this feature in #473 |
Allows `SlackBot::{send,reply}` to receive an optional callback. While this is not documented, if a callback is passed to Hubot's `Response::{send,reply}`, Hubot will pass it around. Shamelessly plagiarized from slackapi#440 because I'm in need of this functionality. Fixed the tests to work with @stubs.
Let me close this PR as #540 has been merged into |
PR Summary
This let's
SlackBot::reply
andSlackBot::send
take an optional callback. While this is not documented, if a callback is passed to Hubot'sResponse::send
andResponse::reply
, Hubot will pass it around..My use case is that, I want to get the
ts
of the message that is sent and then update it later.Related Issues
N/A
Test strategy
Passes the mocha callback to send and reply, so the test will only pass if the callback is called, also checking output to make sure the callback is not related, so not breaking compatibility in any way.