-
Notifications
You must be signed in to change notification settings - Fork 23
/
bootstrap.js
53 lines (42 loc) · 1.01 KB
/
bootstrap.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
52
53
/*
# RUN THE BOT:
Get a Bot token from Slack:
-> http://my.slack.com/services/new/bot
Run your bot from the command line:
token=<MY TOKEN> node index.js
# EXTEND THE BOT:
Botkit has many features for building cool and useful bots!
Read all about it here:
-> http://howdy.ai/botkit
*/
'use strict';
require('dotenv').config();
const { logger } = require('./logger');
let controller = {};
let bot = {};
if (process.env.NODE_ENV == 'development') {
// Interactive shell for bot
const shellbot = require('botkit-shell');
// Initialise Bot Controller
controller = shellbot({});
// Initialise Bot
bot = controller.spawn({});
} else {
const Botkit = require('botkit');
if (!process.env.TOKEN) {
logger.error('Error: Specify token in environment');
process.exit(1);
}
// Initialise Bot Controller
controller = Botkit.slackbot({
debug: false
});
// Initialise Bot
bot = controller.spawn({
token: process.env.TOKEN
});
}
module.exports = {
controller,
bot
};