mirror of
https://github.com/reality/dbot.git
synced 2024-12-25 04:02:39 +01:00
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();
|
dbot.save();
|
||||||
} else {
|
} else {
|
||||||
if(commandName !== '~') {
|
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