-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcli.js
executable file
·41 lines (33 loc) · 934 Bytes
/
cli.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
const req = require('require-yml')
const Bot = require('./')
const createServer = require('./server')
var argv = require('minimist')(process.argv.slice(2))
if (!argv._[0]) {
console.error('cabal /path/to/my/cabal/config.yml')
process.exit(1)
}
let config = req(argv._[0])
console.log(config)
const bot = new Bot({
config: {
dbdir: config.dbdir || '/tmp/cabals'
},
nickname: config.nickname
})
bot.join(config.keys, (err) => {
if (err) throw err
if (argv.port || config.port) {
const server = createServer(bot.say.bind(bot))
server.listen(config.port, () => {
console.log('Listening on', config.port)
})
}
process.stdin.on('data', (data) => {
bot.say(config.keys[0], config.channel, data.toString(), (err) => {
if (err) console.error(err)
})
})
})
bot.on('mention', ({ key, channel, author, message }) => {
console.log('do something', key, channel, author, message)
})