Improved local command processing.
This commit is contained in:
parent
77dc865022
commit
358d01d730
|
|
@ -18,24 +18,19 @@ class commandPreprocessor{
|
|||
//Create an empty array to hold the command
|
||||
this.commandArray = [];
|
||||
//Split string by words
|
||||
const splitString = this.command.split(/\b/g); //Group words together
|
||||
|
||||
//for each word in the splitstring
|
||||
splitString.forEach((string) => {
|
||||
//Add it to our command array
|
||||
this.commandArray.push(string);
|
||||
});
|
||||
this.commandArray = this.command.split(/\b/g);//Split by word-borders
|
||||
this.argumentArray = this.command.match(/\b\w+\b/g);//Match by words surrounded by borders
|
||||
}
|
||||
|
||||
processLocalCommand(){
|
||||
//If this is a local command
|
||||
if(this.commandArray[0] == '/'){
|
||||
//If the command exists
|
||||
if(this.commandProcessor[this.commandArray[1]] != null){
|
||||
if(this.commandProcessor[this.argumentArray[0]] != null){
|
||||
//Don't send it to the server
|
||||
this.sendFlag = false;
|
||||
|
||||
this.commandProcessor[this.commandArray[1]](this.commandArray);
|
||||
this.commandProcessor[this.argumentArray[0]](this.argumentArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,13 +49,13 @@ class commandProcessor{
|
|||
this.client = client
|
||||
}
|
||||
|
||||
high(commandArray){
|
||||
high(argumentArray){
|
||||
//If we have an argument
|
||||
if(commandArray[3]){
|
||||
if(argumentArray[1]){
|
||||
//Use it to set our high level
|
||||
//Technically this is less of a local command than it would be if it where telling the select to do this
|
||||
//but TTN used to treat this as a local command so fuck it
|
||||
this.client.socket.emit("setHighLevel", {highLevel: commandArray[3]});
|
||||
this.client.socket.emit("setHighLevel", {highLevel: argumentArray[1]});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue