Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ npm install slackbots
- `postMessageToGroup(name, message [, params, callback])` (return: promise) - posts a message to private group by name,
- `postMessageToChannel(name, message [, params, callback])` (return: promise) - posts a message to channel by name.
- `openIm(userId)` (return: promise) - opens a direct message channel with another member in the team
- `reconnect()` - reconnects the slackbot to the slack channel after websocket connection times out

## Usage
```js
Expand Down Expand Up @@ -120,4 +121,3 @@ bot.postMessageToUser('user', 'hi').always(function(data) {
// ...
})
```

12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ class Bot extends EventEmitter {
}.bind(this));
}

/**
* Reconnect to Real Time Messaging api after connection is dropped
*/
reconnect() {
this._api('rtm.connect').then((data) => {
this.wsUrl = data.url;
this.connect();
}).fail((data) => {
this.emit('error', new Error(data.error ? data.error : data));
}).done();
}

/**
* Get channels
* @returns {vow.Promise}
Expand Down