Initial logging module [#336]

This commit is contained in:
reality 2013-05-25 19:13:35 +00:00
parent 9792daf669
commit 1e2a823ef2
4 changed files with 37 additions and 0 deletions

View File

@ -51,6 +51,7 @@ var command = function(dbot) {
});
}
}
dbot.api.event.emit('command', [ event ]);
dbot.save();
} else {
if(commandName !== '~') {

7
modules/log/config.json Normal file
View File

@ -0,0 +1,7 @@
{
"logChannel": {
"aberwiki": "#dbot"
},
"ignorable": false,
"dependencies": [ "event", "command" ]
}

24
modules/log/log.js Normal file
View File

@ -0,0 +1,24 @@
/**
* Name: Log
* Description: Log commands to a channel.
*/
var _ = require('underscore')._;
var log = function(dbot) {
this.onLoad = function() {
dbot.api.event.addHook('command', function(event) {
var logChannel = this.config.logChannel[event.server];
if(logChannel) {
dbot.say(event.server, logChannel, dbot.t('log_message', {
'time': new Date().toUTCString(),
'command': event.message,
'user': event.user
}));
}
}.bind(this));
}.bind(this);
};
exports.fetch = function(dbot) {
return new log(dbot);
};

5
modules/log/strings.json Normal file
View File

@ -0,0 +1,5 @@
{
"log_message": {
"en": "[{time}] {user}: {command}"
}
}