-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcore-handlers.js
43 lines (40 loc) · 1010 Bytes
/
core-handlers.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
var config = require('./config')
module.exports = function(bot) {
bot.on('privmsg', function(cmd){
var params = cmd.params.trim().split(' ')
var message = {
sender: cmd.prefix.match(/^:([^!]*)!/)[1],
chan: params.shift(),
msg: params.join(' ').match(/^:(.*)/)[1]
}
bot.emit('msg', message)
})
bot.on('ping', function(cmd) {
bot.emit('cmd', {
cmd: 'PONG',
params: cmd.prefix
})
})
bot.on('notice', function(cmd){
if (cmd.params.trim().indexOf(':*** No Ident response') !== -1) {
bot.emit('cmd', {
cmd: 'PASS',
params: config.user.pass
})
bot.emit('cmd',{
cmd: 'USER',
params: config.user.user + ' 0 * :' + config.user.name
})
bot.emit('cmd',{
cmd: 'NICK',
params: config.user.nick
})
config.chans.forEach(function(chan) {
bot.emit('cmd', {
cmd: 'JOIN',
params: chan.chan + ' ' + chan.pass
})
})
}
})
}