forked from RyanHirsch/irc-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
31 lines (27 loc) · 835 Bytes
/
bot.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
var irc = require('irc'),
config = require('./config.json'),
util = require('util'),
db = require('./db'),
cmds = require('./commands');
var client = new irc.Client(config.irc.server, config.irc.nick, {
channels: config.irc.channels
});
client.addListener('error', function(message) {
console.log('error: ' + message);
});
client.addListener('message', function(from, to, message) {
console.log(util.format('%s => %s: %s', from, to, message));
cmds.processMessage(this, from, to, message);
db.log.add({
ts: new Date(),
server: this.opt.server,
channel: to,
nick: from,
message: message
});
});
client.addListener('pm', function(from, message) {
if(message === '!rehash' ) {
cmds.rehash();
}
});