Repository navigation
Expand file tree
/
Copy pathslackin
More file actions
executable file
·44 lines (36 loc) · 1.58 KB
/
Copy pathslackin
File metadata and controls
executable file
·44 lines (36 loc) · 1.58 KB
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
#!/usr/bin/env node
var pkg = require('./../package')
var args = require('args')
var slackin = require('./../test').default
args
.option(['p', 'port'], 'Port to listen on [$
53C6
PORT or 3000]', require('hostenv').PORT || process.env.PORT || 3000)
.option(['h', 'hostname'], 'Hostname to listen on [$HOSTNAME or 0.0.0.0]', require('hostenv').HOSTNAME || process.env.WEBSITE_HOSTNAME || '0.0.0.0')
.option(['c', 'channels'], 'One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]', process.env.SLACK_CHANNELS)
.option(['i', 'interval'], 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]', process.env.SLACK_INTERVAL || 5000)
.option(['P', 'path'], 'Path to serve slackin under', '/')
.option(['s', 'silent'], 'Do not print out warns or errors')
.option(['x', 'cors'], 'Enable CORS for all routes')
.option(['C', 'coc'], 'Full URL to a CoC that needs to be agreed to')
.option(['S', 'css'], 'Full URL to a custom CSS file to use on the main page')
.option(['?', 'help'], 'Show the usage information')
var flags = args.parse(process.argv, {
value: '<team-id> <api-token>',
help: false
})
var org = args.sub[0] || process.env.SLACK_SUBDOMAIN
var token = args.sub[1] || process.env.SLACK_API_TOKEN
if (flags.help) {
args.showHelp()
}
if (!org || !token) {
args.showHelp()
} else {
flags.org = org
flags.token = token
}
var port = flags.port
var hostname = flags.hostname
slackin(flags).listen(port, hostname, function (err) {
if (err) throw err
if (!flags.silent) console.log('%s – listening on %s:%d', new Date, hostname, port)
})