-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·51 lines (47 loc) · 1.48 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
const { SlackCommand } = require( './command' );
const { setStatus, setPresence, clearStatus } = require( './status' );
const { setTitle } = require( './title' );
const { findConversation, sendMessage } = require( './conversation' );
const { setDND } = require( './dnd.js' );
const command = new SlackCommand( process.argv.slice( 2 ) );
command.init( () => {
// Process any commands that may be accessed by a flag/option
if ( command.hasOwnProperty( 'presence' ) && command.mode !== 'presence' ) {
setPresence( command.workspace, command.presence );
}
if ( command.toggleDND === true ) {
setDND( command.workspace, command.expiration );
}
// Process commands that require an explicit mode to be set
switch ( command.mode ) {
case 'status':
args = {
workspace: command.workspace,
emoji: command.emoji,
text: command.text,
expiration: command.expiration,
};
command.clearStatus
? clearStatus( command.workspace )
: setStatus( args );
break;
case 'send':
sendMessage( command.workspace, command.recipient, command.text );
break;
case 'title':
setTitle( command.workspace, command.title );
break;
case 'dnd':
command.hasOwnProperty( 'expiration' )
? setDND( command.workspace, command.expiration )
: setDND( command.workspace );
break;
case 'presence':
setPresence( command.workspace, command.presence );
break;
default:
console.log( "Sorry, I don't understand that request.".red );
break;
}
} );