forked from GitHub/dbot
Initial logging module [#336]
This commit is contained in:
parent
9792daf669
commit
1e2a823ef2
@ -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
7
modules/log/config.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"logChannel": {
|
||||
"aberwiki": "#dbot"
|
||||
},
|
||||
"ignorable": false,
|
||||
"dependencies": [ "event", "command" ]
|
||||
}
|
24
modules/log/log.js
Normal file
24
modules/log/log.js
Normal 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
5
modules/log/strings.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"log_message": {
|
||||
"en": "[{time}] {user}: {command}"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user