mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 14:29:29 +01:00
initial support for optional command prefix. module commands can currently either use ~command or just command as key, since module loader implements legacy support by shifting the key. there may be a couple of bugs too if there are any recursive commands
This commit is contained in:
parent
6d28aa272b
commit
6204df19c0
@ -166,6 +166,8 @@ var commands = function(dbot) {
|
||||
var configPath = event.input[1],
|
||||
newOption = event.input[2];
|
||||
|
||||
event.reply(event.input[1]);
|
||||
|
||||
if(!_.include(noChangeConfig, configPath)) {
|
||||
this.internalAPI.getCurrentConfig(configPath, function(config) {
|
||||
if(config !== null) {
|
||||
|
@ -12,9 +12,10 @@ var command = function(dbot) {
|
||||
*/
|
||||
this.listener = function(event) {
|
||||
var commandName = event.params[0];
|
||||
if(commandName.charAt(0) != '~') {
|
||||
if(commandName.charAt(0) != this.config.commandPrefix || this.config.passiveMode == true) {
|
||||
return;
|
||||
}
|
||||
commandName = commandName.substring(1);
|
||||
if(!_.has(dbot.commands, commandName)) {
|
||||
if(_.has(dbot.modules, 'quotes')) {
|
||||
var key = event.message.substring(1);
|
||||
@ -23,7 +24,7 @@ var command = function(dbot) {
|
||||
if(quote) {
|
||||
event.reply(key + ': ' + quote);
|
||||
} else if(_.has(dbot.modules, 'spelling')) {
|
||||
var commands = _.keys(dbot.commands)
|
||||
var commands = _.keys(dbot.commands),
|
||||
winner = false,
|
||||
closestMatch = Infinity;
|
||||
|
||||
@ -55,7 +56,7 @@ var command = function(dbot) {
|
||||
}
|
||||
|
||||
else if(_.has(dbot.modules, 'quotes')) {
|
||||
commandName = '~';
|
||||
commandName = this.config.commandPrefix;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -65,7 +66,7 @@ var command = function(dbot) {
|
||||
dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) {
|
||||
dbot.api.ignore.isUserBanned(event.rUser, commandName, function(isBanned) {
|
||||
if(isBanned) {
|
||||
if(this.config.banOutput && commandName != '~') {
|
||||
if(this.config.banOutput && commandName != this.config.commandPrefix) {
|
||||
event.reply(dbot.t('command_ban', {'user': event.user}));
|
||||
}
|
||||
} else if(!hasAccess) {
|
||||
@ -100,10 +101,10 @@ var command = function(dbot) {
|
||||
});
|
||||
}
|
||||
}
|
||||
if(!_.include(['~reload', '~load', '~unload', '~setconfig'], commandName)) dbot.api.event.emit('command', [ event ]);
|
||||
if(!_.include(['reload', 'load', 'unload', 'setconfig'], commandName)) dbot.api.event.emit('command', [ event ]);
|
||||
dbot.save();
|
||||
} else {
|
||||
if(commandName !== '~') {
|
||||
if(commandName !== this.config.commandPrefix) {
|
||||
if(_.has(dbot.usage, commandName)) {
|
||||
event.reply('Usage: ' + dbot.usage[commandName]);
|
||||
} else {
|
||||
|
@ -3,7 +3,7 @@ var _ = require('underscore')._,
|
||||
|
||||
var commands = function(dbot) {
|
||||
return {
|
||||
'~usage': function(event) {
|
||||
'usage': function(event) {
|
||||
var commandName = event.params[1];
|
||||
if(_.has(dbot.usage, commandName)) {
|
||||
event.reply(dbot.t('usage', {
|
||||
|
@ -3,5 +3,7 @@
|
||||
"dependencies": [ "event", "ignore", "users" ],
|
||||
"useNickserv": false,
|
||||
"accessOutput": false,
|
||||
"banOutput": false
|
||||
"banOutput": false,
|
||||
"passiveMode": false,
|
||||
"commandPrefix": "~"
|
||||
}
|
||||
|
8
run.js
8
run.js
@ -316,6 +316,14 @@ DBot.prototype.reloadModules = function() {
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
||||
// Legacy fix for ~ command prefix
|
||||
_.each(this.commands, function(command, cName) {
|
||||
if(cName.charAt(0) == '~') {
|
||||
delete this.commands[cName];
|
||||
this.commands[cName.substring(1)] = command;
|
||||
}
|
||||
}, this);
|
||||
}.bind(this));
|
||||
|
||||
this.save();
|
||||
|
Loading…
Reference in New Issue
Block a user