Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
simple-slack-bot
Advanced tools
Readme
This is Node.js library for easy operation with Slack's Real Time Messaging API.
npm install simple-slack-bot
slack.login
- event fired, when Real Time Messaging API is started (via websocket).slack.logout
- event fired, when bot logout from Slack.ws.message
- event fired, when something happens in Slack. Description of all events here.ws.open
- websocket connection is open and ready to communicate.ws.close
- websocket connection is closed.ws.error
- an error occurred while connecting to Slack.ws.ping
- websocket connection is pinged.ws.pong
- websocket connection is ponged.login()
- Start a connection to Real Time Messaging API,logout()
- Logout from Slack and close websocket connection,setCached(enabled)
- Enable/Disable caching (default: true) to keep channels/groups/users updated,getChannels(callback)
- Returns a list of all channels in the team,getGroups(callback)
- Returns a list of all groups in the team,getUsers(callback)
- Returns a list of all users in the team,getChannelByName(name, callback)
- Gets channel by name,getGroupByName(name, callback)
- Gets group by name,getUserByName(name, callback)
- Gets user by name,getChannelId(name, callback)
- Gets channel ID by name,getGroupId(name, callback)
- Gets group ID by name,getUserId(name, callback)
- Gets user ID by name,getChatId(name, callback)
- Returns or opens and returns a direct message channel id,postMessage(id, text, params, [callback])
(return: promise) - posts a message to channel | group | user by id,updateMessage(channelId, timestamp, text, params, [callback])
- updates a message in a channel,postTo(name, message [, params, callback])
- posts a message to channel | group | user by name,postMessageToUser(name, message [, params, callback])
- posts a direct message by user name,postMessageToGroup(name, message [, params, callback])
- posts a message to private group by name,postMessageToChannel(name, message [, params, callback])
- posts a message to channel by name.var SlackBot = require('simple-slack-bot');
// create a bot
var bot = new SlackBot(
// Slack configuration
{
cached: true, // Enable/Disable caching (default: true)
token: 'xoxb-012345678-ABC1DFG2HIJ3', // Add a bot https://my.slack.com/services/new/bot and put the token
name: 'My Bot'
},
// Websocket connection parameters
{
protocols: {
...
},
options: {
...
}
}
});
bot.on('slack.login', function() {
// more information about additional params https://api.slack.com/methods/chat.postMessage
var params = {
icon_emoji: ':cat:'
};
// define channel, where bot exist. You can adjust it there https://my.slack.com/services
bot.postMessageToChannel('general', 'meow!', params, function (result) {
});
// define existing username instead of 'user_name'
bot.postMessageToUser('user_name', 'meow!', params, function (result) {
});
// If you add a 'slackbot' property,
// you will post to another user's slackbot channel instead of a direct message
bot.postMessageToUser('user_name', 'meow!', { 'slackbot': true, icon_emoji: ':cat:' }, function (result) {
});
// define private group instead of 'private_group', where bot exist
bot.postMessageToGroup('private_group', 'meow!', params, function (result) {
});
// all ingoing events https://api.slack.com/rtm
bot.on('ws.message', function(event) {
console.log('message', event.data);
console.log('flags', event.flags);
});
});
bot.login()
FAQs
Awesome Simple Node.js Slack Bot library
The npm package simple-slack-bot receives a total of 1 weekly downloads. As such, simple-slack-bot popularity was classified as not popular.
We found that simple-slack-bot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.