Logging modules added (requires jsbot support for multi-listeners).

This commit is contained in:
Psychedelic Squid 2012-03-15 05:32:27 +08:00 committed by Luke Slater
parent acb427a24e
commit 9d5cf694a8

41
modules/logging.js Normal file
View File

@ -0,0 +1,41 @@
var logging = function(dbot) {
var logMessage = function(message) {
if(!(dbot.hasOwnProperty('log'))) {
dbot['log'] = [];
}
dbot.log.push([Date.now(), message]);
};
return {
'onLoad': function() {
logMessage({
'type': 'LoggerEvent',
'details': 'Logger loaded.'
});
return {};
},
'onDestroy': function() {
logMessage({
'type': 'LoggerEvent',
'details': 'Logger unloaded.'
});
},
'listener': function(data, eventType) {
logMessage({
'type': 'IRCEvent',
'details': {
'eventType': eventType,
'data': data
}
});
},
'on': ['JOIN', 'PART', 'KICK', 'PRIVMSG', 'MODE']
};
};
exports.fetch = function(dbot) {
return logging(dbot);
};