1.0.1 • Published 6 years ago
slack-send-cli v1.0.1
Slack CLI sending messages by webhook
Install
Globally:
$ npm install -g slack-send-cli
$ slack-send Test messageLocally:
$ npm install slack-send-cli
$ npx slack-send Test messageCLI usage
slack-send '<Text message>'Configuration
- Defaults from hook settings
Environment variables:
SLACK_SEND_CLI_URLSLACK_SEND_CLI_CHANNELSLACK_SEND_CLI_EMOJISLACK_SEND_CLI_PICTURESLACK_SEND_CLI_USERNAME
Options:
-w --webhook <url>— Slack webhook URL-c --channel <name>— Channel or user name, e.g.some_channel,#channel,@username-e --emoji <name>— Emoji name for userpic, e.g.:confused:,:confused:-p --picture <url>— Userpic URL-n --username <username>— Username-s --status <username>— Message status, e.g.error,fail,success,warning,warn,info,#FF0000
Programmatically usage
As class:
const SlackSend = require('slack-send-cli');
const slack = new SlackSend({
webhook: 'https://hooks.slack.com/services/...'
channel: 'general'
emoji: 'confused'
picture: 'https://cdn...'
username: 'Alert Bot'
});
slack.send('Hello world!', 'success', (err) => {
if (err) {
console.error(err);
return;
}
}).then( () => {
console.log('ok')
}, err => {
console.error(err);
});Or as function:
const slack = require('slack-send-cli');
slack.send({
webhook: 'https://hooks.slack.com/services/...'
channel: 'general'
emoji: 'confused'
picture: 'https://cdn...'
username: 'Alert Bot'
}, 'Hello world!', 'success', (err) => {
if (err) {
console.error(err);
return;
}
}).then( () => {
console.log('ok')
}, err => {
console.error(err);
});Class
constructor(params)[Object]params[String]webhook[String]channel[String]emoji[String]picture[String]username
returns
[class SlackSend]
send(message, [status], [callback])[String]message[String]status (optional)[Function]status (optional)- returns
Promise
Function
send(params, message, [status], [callback])[Object]params[String]webhook[String]channel[String]emoji[String]picture[String]username
[String]message[String]status (optional)[Function]status (optional)- returns
Promise