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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ npm install slackbots
- `postMessageToUser(name, message [, params, callback])` (return: promise) - posts a direct message by user name,
- `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.
- `postReactionToChannel(channel, emoji, timestamp [, params, callback])` (return: promise) - posts a reaction (emoji) to a channel's message by timestamp.
- `removeReactionFromChannel(channel, emoji, timestamp [, params, callback])` (return: promise) - removes a reaction (emoji) from a channel's message by timestamp.
- `getReactions(channel, timestamp [, params, callback])` (return: promise) - returns a list of all reactions for a message by timestamp.
- `listReactions(user [, params, callback])` (return: promise) - returns a list of all items reacted to by a user.
- `openIm(userId)` (return: promise) - opens a direct message channel with another member in the team

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

/**
* Posts a reaction (emoji) to a message by timestamp
* @param {string} id - channel ID
* @param {string} emoji - emoji string (without the : symbols)
* @param {string} ts - timestamp
* @param {object} params
* @returns {vow.Promise}
*/
postReactionToChannel(id, emoji, ts, params) {
params = extend({
channel: id,
name: emoji,
timestamp: ts
}, params || {});

return this._api('reactions.add', params);
};

/**
* Removes a reaction (emoji) by timestamp
* @param {string} id - channel ID
* @param {string} emoji - emoji string (without the : symbols)
* @param {string} ts - timestamp
* @param {object} params
* @returns {vow.Promise}
*/
removeReactionFromChannel(id, emoji, ts, params) {
params = extend({
channel: id,
name: emoji,
timestamp: ts
}, params || {});

return this._api('reactions.remove', params);
};

/**
* Returns a list of all reactions for a message by timestamp
* @param {string} id - channel ID
* @param {string} ts - timestamp of the message
* @param {object} params
* @returns {vow.Promise}
*/
getReactions(id, ts, params) {
params = extend({
channel: id,
timestamp: ts
}, params || {});

return this._api('reactions.get', params);
};

/**
* Returns a list of all items reacted to by a user
* @param {string} id - user ID
* @param {object} params
* @returns {vow.Promise}
*/
listReactions(id, ts, params) {
params = extend({
user: id
}, params || {});

return this._api('reactions.list', params);
};

/**
* Remove @ or # character from group | channel | user name
* @param {string} name
Expand Down