Modified commandPreprocessor to be easily shared between chat.js and pmHandler.js
This commit is contained in:
parent
d465863ee6
commit
b26dd1094c
|
|
@ -274,7 +274,7 @@ class chatBox{
|
|||
* @param {String} user - User to toke with
|
||||
*/
|
||||
tokeWith(user){
|
||||
this.commandPreprocessor.preprocess(user == this.client.user.user ? "!toke up fuckers" : `!toke up ${user}`);
|
||||
this.transmit(user == this.client.user.user ? "!toke up fuckers" : `!toke up ${user}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -283,7 +283,9 @@ class chatBox{
|
|||
*/
|
||||
send(event){
|
||||
if((!event || !event.key || event.key == "Enter") && this.chatPrompt.value){
|
||||
this.commandPreprocessor.preprocess(this.chatPrompt.value);
|
||||
//Transmit the chat
|
||||
this.transmit(this.chatPrompt.value);
|
||||
|
||||
//Clear our prompt and autocomplete nodes
|
||||
this.chatPrompt.value = "";
|
||||
this.autocompletePlaceholder.innerHTML = '';
|
||||
|
|
@ -291,6 +293,17 @@ class chatBox{
|
|||
}
|
||||
}
|
||||
|
||||
transmit(msg){
|
||||
//Pre-process chat string
|
||||
const preprocessedChat = this.commandPreprocessor.preprocess(msg);
|
||||
|
||||
//If we passed through pre-processing
|
||||
if(preprocessedChat != false){
|
||||
//Send pre-processed chat data off to server
|
||||
this.client.socket.emit("chatMessage", preprocessedChat);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays auto-complete text against current prompt input
|
||||
* @param {Event} event - Event passed down from Event Handler
|
||||
|
|
|
|||
|
|
@ -73,13 +73,19 @@ class commandPreprocessor{
|
|||
if(this.sendFlag){
|
||||
//Set the message to the command
|
||||
this.message = command;
|
||||
|
||||
//Process message emotes into links
|
||||
this.processEmotes();
|
||||
|
||||
//Process unmarked links into marked links
|
||||
this.processLinks();
|
||||
//Send command off to server
|
||||
this.sendRemoteCommand();
|
||||
|
||||
//Return pre-processed message data
|
||||
return {msg: this.message, links: this.links};
|
||||
}
|
||||
|
||||
//Return false for bad message/command on fall-through
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -150,13 +156,6 @@ class commandPreprocessor{
|
|||
this.message = splitMessage.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Transmits message/command off to server
|
||||
*/
|
||||
sendRemoteCommand(){
|
||||
this.client.socket.emit("chatMessage",{msg: this.message, links: this.links});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets site emotes
|
||||
* @param {Object} data - Emote data from server
|
||||
|
|
|
|||
Loading…
Reference in a new issue