Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'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');
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);
});
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);
});