-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.js
executable file
·46 lines (39 loc) · 1.09 KB
/
bin.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
#!/usr/bin/env node
var gitterBot = require('./')
function getIrcOpts () {
var ircOpts = process.env['GITTERBOT_IRC_OPTS']
if (ircOpts) {
try {
ircOpts = JSON.parse(process.env['GITTERBOT_IRC_OPTS'])
} catch (err) {
console.error('Invalid JSON in GITTERBOT_IRC_OPTS')
process.exit(1)
}
}
return ircOpts || {}
}
var opts = {
ircServer: "irc.freenode.net",
ircChannel: "#vimfest",
ircNick: "vimfestbot",
ircAdmin: "wikimatze",
ircOpts: getIrcOpts(),
gitterApiKey: "7e414e411a585b2e65a35de50f18c9d47b525a53",
gitterRoom: "vimberlin/vimfest"
}
if (!((opts.ircChannel || opts.ircOpts.channels) &&
opts.gitterApiKey && opts.gitterRoom && opts.ircNick)) {
console.error('You need to set the config env variables (see readme.md)')
process.exit(1)
}
var herokuURL = process.env.HEROKU_URL
if (herokuURL) {
var request = require('request')
require('http').createServer(function (req, res) {
res.end('ping heroku\n')
}).listen(process.env.PORT)
setInterval(function () {
request(herokuURL).pipe(process.stdout)
}, 5 * 60 * 1000)
}
gitterBot(opts)