Skip to content

Commit

Permalink
Merge branch 'master' into feature/upgrade-coffeescript-2
Browse files Browse the repository at this point in the history
phucnh authored Sep 3, 2019
2 parents 3165362 + ed96aca commit 2266069
Showing 3 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"stopOnEntry": false,
"args": [
"--compilers",
"coffee:coffeescript/register",
"--require",
"coffeescript/register",
"--no-timeouts"
],
"cwd": "${workspaceFolder}",
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
"scripts": {
"test": "npm run mocha && istanbul report text-summary lcov",
"codecov": "codecov",
"mocha": "mocha --compilers coffee:coffeescript/register --require coffee-coverage/register-istanbul --reporter spec test"
"mocha": "mocha --require coffeescript/register --require coffee-coverage/register-istanbul --reporter spec test/*.coffee"
},
"keywords": [
"hubot",
21 changes: 15 additions & 6 deletions src/bot.coffee
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ class SlackBot extends Adapter
# SlackClient event handlers
@client.rtm.on "open", @open
@client.rtm.on "close", @close
@client.rtm.on "disconnect", @disconnect
@client.rtm.on "error", @error
@client.rtm.on "authenticated", @authenticated
@client.onEvent @eventHandler
@@ -178,16 +179,24 @@ class SlackBot extends Adapter
# @private
###
close: =>
@robot.logger.info "Disconnected from Slack RTM"
# NOTE: not confident that @options.autoReconnect works
if @options.autoReconnect
@robot.logger.info "Disconnected from Slack RTM"
@robot.logger.info "Waiting for reconnect..."
else
@robot.logger.info "Exiting..."
@client.disconnect()
# NOTE: Node recommends not to call process.exit() but Hubot itself uses this mechanism for shutting down
# Can we make sure the brain is flushed to persistence? Do we need to cleanup any state (or timestamp anything)?
process.exit 1
@disconnect()

###*
# Slack client has closed the connection and will not reconnect
# @private
###
disconnect: =>
@robot.logger.info "Disconnected from Slack RTM"
@robot.logger.info "Exiting..."
@client.disconnect()
# NOTE: Node recommends not to call process.exit() but Hubot itself uses this mechanism for shutting down
# Can we make sure the brain is flushed to persistence? Do we need to cleanup any state (or timestamp anything)?
process.exit 1

###*
# Slack client received an error

0 comments on commit 2266069

Please sign in to comment.