-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlunchBot.js
More file actions
38 lines (34 loc) · 881 Bytes
/
lunchBot.js
File metadata and controls
38 lines (34 loc) · 881 Bytes
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
var botkit = require('botkit');
var request = require('request');
var CONFIG = require('./config.json');
var LunchBot = require('./classes/LunchBot');
var LB = {};
if (!process.env.token) {
// if token is not defined try to load environment variables from .env file.
console.log('Error: Specify token in environment', require('dotenv').config());
require('dotenv').config();
}
if (!process.env.token) {
console.log('Error: Specify token in environment');
process.exit(1);
}
var controller = botkit.slackbot({
stale_connection_timeout: 120000,
debug: true,
json_file_store: './storage'
});
/**
* Init code. When the RTM API starts, we call `LunchBot.begin`.
*/
controller.spawn({
token: process.env.token
}, function (bot) {
LB = new LunchBot(bot, controller);
LB.bot.startRTM((err)=>{
if(err){
console.error(err);
process.exit();
}
LB.begin();
});
});