diff --git a/modules/command/command.js b/modules/command/command.js index 776299c..cab3439 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -51,6 +51,7 @@ var command = function(dbot) { }); } } + dbot.api.event.emit('command', [ event ]); dbot.save(); } else { if(commandName !== '~') { diff --git a/modules/log/config.json b/modules/log/config.json new file mode 100644 index 0000000..d4b8475 --- /dev/null +++ b/modules/log/config.json @@ -0,0 +1,7 @@ +{ + "logChannel": { + "aberwiki": "#dbot" + }, + "ignorable": false, + "dependencies": [ "event", "command" ] +} diff --git a/modules/log/log.js b/modules/log/log.js new file mode 100644 index 0000000..a799672 --- /dev/null +++ b/modules/log/log.js @@ -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); +}; diff --git a/modules/log/strings.json b/modules/log/strings.json new file mode 100644 index 0000000..c25d7a8 --- /dev/null +++ b/modules/log/strings.json @@ -0,0 +1,5 @@ +{ + "log_message": { + "en": "[{time}] {user}: {command}" + } +}