Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tarquas/slack-web-info


https://github.com/tarquas/slack-web-info

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

Slack Web Info
==============

Slack bulk information provider high-scalable NodeJS module

This is official code repository of this project.

## Project Official Website

http://194.44.203.87/projects/slack-web-info/

# Installation

$ `npm i slack-web-info`

# Quick Usage

```javascript
var SlackWebInfo = require( 'slack-web-info' );

var config = {
company : 'mycompany', // use 'http://mycompany.slack.com/` entry
email : '[email protected]', // logon data
password : 'bot-password',
cacheTime : 2 * 60 * 1000, // cache information for 2 minutes
};

var slackInfo = new SlackWebInfo( config );

slackInfo.getInfo( [ 'users', 'presence', 'active' ], function( err, info ) {

if ( info ) {
console.log(
'Full names of users with "online" status:',
info.map( function( user ) { return user.profile.real_name; }
)
} else
console.log( 'No users with "online" status found' );
} )

slackInfo.getInfo( [ 'users', 'real_name', 'John Smith' ], function( err, info ) {

if ( info ) {
console.log(
'Is John Smith "online"?',
info.presence == 'active' ? 'Yes' : 'No'
)
} else
console.log( 'John Smith is not found' );
} )

slackInfo.getInfo( [ 'users', 'email', '[email protected]' ], function( err, info ) {

if ( info ) {
console.log( 'Data of user with email: [email protected]' );
console.log( ' Phone:', info.profile.phone || 'Not Specified' );
console.log( ' Time Zone:', info.tz );
} else
console.log( 'User with email: [email protected] not found' );
} )

slackInfo.getInfo( [ 'users' ], function( err, info ) {

if ( !err ) {
var
humans = users.is_bot.false,
nHumans = humans ? humans.length : 0,

bots = users.is_bot.true,
nBots = bots ? bots.length : 0;

console.log(
'Employees:',
info.presence.active.length - nBots, 'online from',
nHumans, 'total'
)
} else
console.log( 'Error:', err );
} )

```