Gathering detailed insights and metrics for seed-slackbot
Gathering detailed insights and metrics for seed-slackbot
Gathering detailed insights and metrics for seed-slackbot
Gathering detailed insights and metrics for seed-slackbot
npm install seed-slackbot
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
$ npm install seed-slackbot
Options should contain a token
field that is string.
Options could contain a processSlackbot
field, that is an optional boolean and false by default
Options could contain a processReplies
field, that is an optional boolean and false by default
Options could contain a processSubtypes
field, that is an optional boolean and false by default
Options could contain a processSelf
field, that is an optional boolean and false by default
Options could contain a mock
field, that is an optional boolean and false by default
1var Slack = require('seed-slackbot'); 2var slack = new Slack({ token: 'ABC123', processReplies: true }); 3var slack = new Slack('ABC123'); // shorthand
Used to call slack web api
1slack.request('chat.postMessage', msg, function(err, result) {});
Get channel by name or id
1var channel = slack.channel('C1234');
Get user by name or id
1var user = slack.user('U4567');
Get IM by id or user name or user id
1var im = slack.im('C5678');
Get current user
1var self = slack.self();
Send message to channel
1slack.send('1234', 'Hello world!'); 2slack.send({ type: 'message', channel: '1234', text: 'Hello world!' }); // alternative
Get slackbot's internal duplex stream
1var stream = slack.stream(); 2 3stream.pipe(through(function(message, enc, cb) { 4 if (message.type === 'presence_change' && message.user.id === slack.self().id) { 5 this.push(['test', 'I\'m back!']); 6 } 7 cb(); 8})).pipe(stream);
1var Slack = require('seed-slackbot'); 2var slack = new Slack({ token: process.env.SLACK_TOKEN }); 3 4slack.on('message', function(data) { 5 slack.send(channel, message); 6 slack.request('chat.postMessage', msg, function(err, result) { 7 8 }); 9});
It's possible to mock slack transports to test slackbot and it's dependents
1var slack = new Slack({ mock: true }); 2 3// simulate a message coming from slack 4slack.mock(JSON.stringify({ 5 channel: 'C123', 6 type: 'message', 7 text: 'Hello world', 8 user: 'U123' 9})); 10 11// examine messages going to slack 12slack.on('mock:message', function(payload) { 13 console.log(JSON.parse(payload)); 14}); 15 16// examine requests going to slack and simulate slack response 17slack.on('mock:request', function(data) { 18 // data.url 19 // data.method 'rtm.start' 20 // data.data {} 21 // data.callback 22 data.callback(null, { data: { users: [{}], channels: [{}], groups: [], ims: [{}], ...} }); 23});
Buffer stream until slack is connected
MIT
No vulnerabilities found.
No security vulnerabilities found.