-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcatbot.js
More file actions
42 lines (31 loc) · 1.2 KB
/
Copy pathcatbot.js
File metadata and controls
42 lines (31 loc) · 1.2 KB
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
const catbotModule = require('./catbot-runner');
// In the future we should serve a pretty webpage with user stats!
// For now we have a simple app that doesn't do anything but listen
// and serve a dummy webpage
const express = require('express');
const proxy = require('express-http-proxy');
const bodyParser = require('body-parser');
const _ = require('lodash');
var http_port = process.env.PORT || '8080';
var bot_name = process.env.BOT_NAME ||'catbot';
var slackToken = process.env.SLACK_API_TOKEN;
var slackClient = require('@slack/client');
var app = express();
if (process.env.PROXY_URI) {
app.use(process.env.PROXY_URI), {
forwardPath: function(req, res) { return require('url').parse(req.url).path }
}
}
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/', function(req, res) { res.send('\n 😻😻 ' + bot_name + ' 😻😻 \n') });
app.use(express.static(__dirname + '/assets'));
app.listen(http_port, function(err) {
if (err) {
throw err;
}
console.log('Listening on ' + http_port);
var catbotRunner = new catbotModule.CatRunner();
catbotRunner.init(slackClient.RtmClient, slackClient.RTM_EVENTS, slackToken);
catbotRunner.start();
});