-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
33 lines (28 loc) 路 734 Bytes
/
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
const Botkit = require("botkit");
const config = require("./config.js");
const taco = require("./taco.js");
const tacobot = require("./bot.js");
const schedule = require("node-schedule");
const controller = Botkit.slackbot(config.controller);
const bot = controller.spawn({
token: config.token,
});
const startRTM = () => {
bot.startRTM((err, _bot, _payload) => {
if (err) {
console.log(err);
return setTimeout(startRTM, 60000);
} else {
console.log("Ready to taco !");
taco.init();
tacobot.listens(controller);
}
});
};
controller.on("rtm_close", function (_bot, _err) {
startRTM();
});
startRTM();
schedule.scheduleJob({ hour: 00, minute: 00 }, () => {
taco.resetLeft();
});