-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandlers.js
43 lines (37 loc) · 1.3 KB
/
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 handlers = {};
var config = require('config');
var commands = require('commands');
console.log('handlers.js loading');
var init_options;
var command;
var argv;
handlers.handlersByEventname = {
join: function (bot,channel, who) {
who = who.toLowerCase();
console.log(who);
console.log(config.friends.indexOf(who));
console.log(config.friends);
if(config.friends.indexOf(who) >=0){
init_options.bot.say(master,who + " joined "+channel);
}
},
message: function (bot,from, to, message) {
// console.log('bot:'); console.log(bot);
console.log('from:'); console.log(from);
console.log('to:'); console.log(to);
console.log('message:'); console.log(message);
if(message && message.indexOf ) {
console.log('message.indexOf(config.COMMAND_DELIMITER):'); console.log(message.indexOf(config.COMMAND_DELIMITER));
if(message.indexOf(config.COMMAND_DELIMITER) == 0) {
argv = message.substring(1).split(' ').filter(String);
command = argv[0];
if(command_handler = require('commands').handlers[command])
{
command_handler.apply(null,[bot,from,to,message,argv]);
}
}
}
}
}
handlers.eventnames = Object.keys(handlers.handlersByEventname);
module.exports = handlers;