How to use the @slack/client.RTM_EVENTS.REACTION_ADDED function in @slack/client

To help you get started, we’ve selected a few @slack/client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slackapi / node-slack-sdk / examples / example-rtm-client.js View on Github external
/* eslint no-console:0 */

var RtmClient = require('@slack/client').RtmClient;
var RTM_EVENTS = require('@slack/client').RTM_EVENTS;

var token = process.env.SLACK_API_TOKEN || '';

var rtm = new RtmClient(token, { logLevel: 'debug' });
rtm.start();

rtm.on(RTM_EVENTS.MESSAGE, function handleRtmMessage(message) {
  console.log('Message:', message);
});

rtm.on(RTM_EVENTS.REACTION_ADDED, function handleRtmReactionAdded(reaction) {
  console.log('Reaction added:', reaction);
});

rtm.on(RTM_EVENTS.REACTION_REMOVED, function handleRtmReactionRemoved(reaction) {
  console.log('Reaction removed:', reaction);
});
github lvn / botstrap / lib / message.js View on Github external
}

    // deal with some event jankiness
    if (typeof channel === 'string') {
      this.channel = bot.rtm.dataStore.
        getChannelGroupOrDMById(channel);
    } else {
      this.channel = channel;
    }

    this.reactions = [];
    this.reactionSubscribers = [];
    this.reactionBuffer = [];

    // single callback for subscriptions
    this.bot.on(RTM_EVENTS.REACTION_ADDED, (reaction, context) => {
      if (this._message &&
        reaction.item.channel === this.channel.id &&
        reaction.item.ts === this._message.ts &&
        reaction.user != this.bot.self.id) {

        this.reactions.push(reaction);
        context.reaction = reaction;

        // notify subscribers
        this.reactionSubscribers.forEach(cb =>
          bot.injectedInvoke(cb, context));
      }
    });
  }
github lvn / botstrap / lib / constants.js View on Github external
'star_added': ['message'],
  'star_removed': ['message'],
  'raw_message': ['message'],
  'presenceChange': ['user', 'presence'],
  'statusChange': ['user', 'status'],
  'message': ['message'],
  'channelMarked': ['channel', 'ts'],
  'userTyping': ['user', 'channel'],
  'userChange': ['user'],
  'botRemoved': ['bot'],
  'messageSent': ['message'],
  'throw': ['error']
};

// new style events
eventArgs[RTM_EVENTS.REACTION_ADDED] = ['reaction'];
eventArgs[RTM_EVENTS.REACTION_REMOVED] = ['reaction'];
eventArgs[RTM_EVENTS.MESSAGE] = ['message'];

exports.eventArgs = eventArgs;

exports.errMsgs = {
  'err_plugin_type': 'Plugin type {{type}} does not exist!',
  'err_token': 'No token found!'
};

exports.NotImplementedError = new Error('Not implemented');
github slackapi / node-slack-sdk / examples / example-rtm-client-datastore.js View on Github external
rtm.start();

rtm.on(CLIENT_EVENTS.RTM.AUTHENTICATED, function handleRTMAuthenticated() {
  console.log('RTM client authenticated!');
});

rtm.on(RTM_EVENTS.MESSAGE, function handleRtmMessage(message) {
  console.log(
    'User %s posted a message in %s channel',
    rtm.dataStore.getUserById(message.user).name,
    rtm.dataStore.getChannelGroupOrDMById(message.channel).name
  );
});

rtm.on(RTM_EVENTS.REACTION_ADDED, function handleRtmReactionAdded(reaction) {
  console.log('Reaction added:', reaction);
});

rtm.on(RTM_EVENTS.REACTION_REMOVED, function handleRtmReactionRemoved(reaction) {
  console.log('Reaction removed:', reaction);
});