-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (46 loc) · 1.65 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
45
46
47
48
49
50
51
52
53
54
55
56
require("dotenv").config();
if (!process.env.SLACK_TOKEN || !process.env.REDISCLOUD_URL) {
console.log("Error: Specify SLACK_TOKEN and REDISCLOUD_URL in environment"); // eslint-disable-line no-console
process.exit(1); // eslint-disable-line unicorn/no-process-exit
}
const path = require("path");
const url = require("url");
const http = require("http");
const redis = require("botkit-storage-redis");
const botkit = require("botkit");
const awYissController = require("./src/skills/aw-yiss/controller");
const bukkitController = require("./src/skills/bukkit/controller");
const benedictCumberbatchController = require("./src/skills/benedict-cumberbatch/controller");
const normalizedPath = path.join(__dirname, "skills");
const redisURL = url.parse(process.env.REDISCLOUD_URL);
const redisStorage = redis({
namespace: "botkit-otterbot",
host: redisURL.hostname,
port: redisURL.port,
auth_pass: redisURL.auth.split(":")[1] // eslint-disable-line camelcase
});
const controller = botkit.slackbot({
debug: true,
stats_optout: true, // eslint-disable-line camelcase
storage: redisStorage
});
controller
.spawn({
token: process.env.SLACK_TOKEN
})
.startRTM();
require("fs")
.readdirSync(normalizedPath)
.forEach(file => {
require(`./skills/${file}`)(controller); // eslint-disable-line import/no-dynamic-require
});
awYissController(controller);
bukkitController(controller);
benedictCumberbatchController(controller);
// To keep Heroku's free dyno awake
http
.createServer((request, response) => {
response.writeHead(200, { "Content-Type": "text/plain" });
response.end("Ok, dyno is awake.");
})
.listen(process.env.PORT || 5000);