-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (36 loc) · 1.45 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
if (!process.env.SLACK_CLIENT_ID || !process.env.SLACK_CLIENT_SECRET || !process.env.PORT) {
usage_tip();
return;
}
const Botkit = require('botkit');
const debug = require('debug')('botkit:main');
const controller = Botkit.slackbot({
clientId: process.env.SLACK_CLIENT_ID,
clientSecret: process.env.SLACK_CLIENT_SECRET,
scopes: ['bot', 'channels:history', 'chat:write:bot', 'reactions:read'],
redirectUri: 'https://beefcakes.club:8443/oauth',
json_file_store: '/usr/src/app/.data/filedb/',
});
controller.startTicking();
// Set up an Express-powered webserver to expose oauth and webhook endpoints
const webserver = require('./components/express_webserver.js')(controller);
webserver.get('/', function(req, res){
res.render('index', {
domain: req.get('host'),
protocol: req.protocol,
layout: 'layouts/default'
});
})
require('./components/user_registration.js')(controller);
require('./components/onboarding.js')(controller);
const normalizedPath = require("path").join(__dirname, "skills");
require("fs").readdirSync(normalizedPath).forEach(function(file) {
require("./skills/" + file)(controller);
});
function usage_tip() {
console.log('~~~~~~~~~~');
console.log('Execute your bot application like this:');
console.log('SLACK_CLIENT_ID=<MY SLACK CLIENT ID> SLACK_CLIENT_SECRET=<MY CLIENT SECRET> PORT=3000 node index.js');
console.log('Get Slack app credentials here: https://api.slack.com/apps')
console.log('~~~~~~~~~~');
}