add !whisper command for tiny chats

This commit is contained in:
rainbow napkin 2024-12-08 13:05:09 -05:00
parent 4c1f0f10a7
commit 0182c6927e
6 changed files with 92 additions and 37 deletions

View file

@ -76,31 +76,31 @@ class chatBox{
});
}
displayChat(chat){
displayChat(data){
//Create chat-entry span
var chatEntry = document.createElement('span');
chatEntry.classList.add("chat-panel-buffer","chat-entry",`chat-entry-${chat.user}`);
chatEntry.classList.add("chat-panel-buffer","chat-entry",`chat-entry-${data.user}`);
//Create high-level label
var highLevel = document.createElement('p');
highLevel.classList.add("chat-panel-buffer","chat-entry-high-level","high-level");
highLevel.innerHTML = `${chat.highLevel}`;
highLevel.innerHTML = `${data.highLevel}`;
chatEntry.appendChild(highLevel);
//Create username label
var userLabel = document.createElement('p');
userLabel.classList.add("chat-panel-buffer","chat-entry-username");
if(chat.flair != "classic"){
var flair = `flair-${chat.flair}`;
if(data.flair != "classic"){
var flair = `flair-${data.flair}`;
}else{
var flair = this.client.userList.colorMap.get(chat.user);
var flair = this.client.userList.colorMap.get(data.user);
}
//Create color span
var colorSpan = document.createElement('span');
colorSpan.classList.add("chat-entry-flair-span", flair);
colorSpan.innerHTML = `${chat.user}`;
colorSpan.innerHTML = `${data.user}`;
userLabel.innerHTML = `${colorSpan.outerHTML}: `;
chatEntry.appendChild(userLabel);
@ -108,11 +108,11 @@ class chatBox{
//Create chat body
var chatBody = document.createElement('p');
chatBody.classList.add("chat-panel-buffer","chat-entry-body");
chatBody.innerHTML = chat.msg;
chatBody.innerHTML = data.msg;
chatEntry.appendChild(chatBody);
this.chatBuffer.appendChild(this.chatPreprocessor.preprocess(chatEntry));
this.chatBuffer.appendChild(this.chatPreprocessor.preprocess(chatEntry, data));
//Set size to aspect on launch
this.resizeAspect();

View file

@ -2,7 +2,8 @@ class chatPreprocessor{
constructor(){
}
preprocess(chatEntry){
preprocess(chatEntry, rawData){
this.rawData = rawData;
//Set current chat nodes
this.chatEntry = chatEntry;
this.chatBody = this.chatEntry.querySelector(".chat-entry-body");
@ -12,6 +13,9 @@ class chatPreprocessor{
//Inject whitespace into un-processed words
this.addWhitespace();
//Sush chat if it's a whisper
this.handleChatType();
//Inject the pre-processed chat into the chatEntry node
this.injectBody();
@ -73,4 +77,10 @@ class chatPreprocessor{
}
});
}
handleChatType(){
if(this.rawData.type == "whisper"){
this.chatBody.classList.add('whisper');
}
}
}

View file

@ -31,7 +31,7 @@ class commandPreprocessor{
this.sendFlag = false;
//Call the command with the argument array
this.commandProcessor[this.argumentArray[0]](this.argumentArray);
this.commandProcessor[this.argumentArray[0]](this.argumentArray, this.commandArray);
}
}
}