Added proper toke and username autocompletion.
This commit is contained in:
parent
23a71a5478
commit
acbe0400c4
7 changed files with 76 additions and 20 deletions
|
|
@ -32,6 +32,7 @@ class commandPreprocessor{
|
|||
this.client.socket.on("siteEmotes", this.setSiteEmotes.bind(this));
|
||||
this.client.socket.on("chanEmotes", this.setChanEmotes.bind(this));
|
||||
this.client.socket.on("personalEmotes", this.setPersonalEmotes.bind(this));
|
||||
this.client.socket.on("usedTokes", this.setUsedTokes.bind(this));
|
||||
}
|
||||
|
||||
preprocess(command){
|
||||
|
|
@ -124,6 +125,10 @@ class commandPreprocessor{
|
|||
this.emotes.personal = data;
|
||||
}
|
||||
|
||||
setUsedTokes(data){
|
||||
this.usedTokes = data.tokes;
|
||||
}
|
||||
|
||||
getEmoteByLink(link){
|
||||
//Create an empty variable to hold the found emote
|
||||
var foundEmote = null;
|
||||
|
|
@ -161,33 +166,37 @@ class commandPreprocessor{
|
|||
}
|
||||
|
||||
buildAutocompleteDictionary(){
|
||||
//This isn't complete, just a placeholder for now
|
||||
let dictionary = {
|
||||
tokes: {
|
||||
prefix: '!',
|
||||
postfix: '',
|
||||
cmds: [
|
||||
"toke"
|
||||
]
|
||||
cmds: this.usedTokes
|
||||
},
|
||||
//Make sure to add spaces at the end for commands that take arguments
|
||||
//Not necissary but definitely nice to have
|
||||
serverCMD: {
|
||||
prefix: '!',
|
||||
postfix: '',
|
||||
cmds: [
|
||||
"whisper",
|
||||
"announce",
|
||||
"serverannounce",
|
||||
"clear",
|
||||
"kick"
|
||||
"whisper ",
|
||||
"announce ",
|
||||
"serverannounce ",
|
||||
"clear ",
|
||||
"kick "
|
||||
]
|
||||
},
|
||||
localCMD:{
|
||||
prefix: '/',
|
||||
postfix: '',
|
||||
cmds: [
|
||||
"high"
|
||||
"high "
|
||||
]
|
||||
},
|
||||
usernames:{
|
||||
prefix: '',
|
||||
postfix: '',
|
||||
cmds: Array.from(client.userList.colorMap.keys())
|
||||
},
|
||||
emotes:{
|
||||
prefix:'[',
|
||||
postfix:']',
|
||||
|
|
@ -195,6 +204,23 @@ class commandPreprocessor{
|
|||
}
|
||||
};
|
||||
|
||||
//Ensure default toke command
|
||||
//Check if 'toke' is the first registered toke
|
||||
if(dictionary.tokes.cmds[0] != 'toke'){
|
||||
//Find the current place of the 'toke' command, if any
|
||||
const tokeIndex = dictionary.tokes.cmds.indexOf('toke');
|
||||
|
||||
//If the default command is present but is out of order
|
||||
if(tokeIndex != -1){
|
||||
//Splice it out
|
||||
dictionary.tokes.cmds.splice(tokeIndex,1);
|
||||
}
|
||||
|
||||
//Throw it into the beggining of the array
|
||||
dictionary.tokes.cmds.unshift('toke');
|
||||
}
|
||||
|
||||
//return our dictionary object
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue