Added basic ignore/unignore functionality
This commit is contained in:
parent
999fae91b7
commit
b80f82b9f2
6 changed files with 139 additions and 1 deletions
|
|
@ -129,7 +129,9 @@ class channel{
|
|||
|
||||
this.socket.on("archive", (data) =>{
|
||||
this.sortQueue(data.archive);
|
||||
})
|
||||
});
|
||||
|
||||
this.socket.on("ignore", this.handleIgnoredList.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -169,6 +171,21 @@ class channel{
|
|||
this.streamType = data.streamType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated ignore list
|
||||
* @param {Array} data - Ignore list received from server
|
||||
*/
|
||||
handleIgnoredList(data){
|
||||
//Update ignored users list
|
||||
this.user.ignored = data;
|
||||
|
||||
//If we have the chatbox loaded in
|
||||
if(this.chatBox != null){
|
||||
//Re-render buffer
|
||||
this.chatBox.rerenderBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts queue, optionally adding new items along the way
|
||||
* @param {object} queueData - Contains list of entries to add to the queue
|
||||
|
|
|
|||
|
|
@ -229,6 +229,16 @@ class chatBox{
|
|||
* @param {Object} data De-hydrated chat object from server
|
||||
*/
|
||||
displayChat(data){
|
||||
|
||||
//For every douchebag in the ignored users list
|
||||
for(const douchebag of this.client.user.ignored){
|
||||
//If this message is from the douchebag in question
|
||||
if(data.user == douchebag.user){
|
||||
//tell it to fuck off and die
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Append the post-processed chat-body to the chat buffer
|
||||
this.chatBuffer.appendChild(this.chatPostprocessor.postprocess(data));
|
||||
|
||||
|
|
|
|||
|
|
@ -196,6 +196,26 @@ class userList{
|
|||
]);
|
||||
|
||||
if(user.user != "Tokebot" && user.user != this.client.user.user){
|
||||
let ignored = false;
|
||||
|
||||
//For each douchebag in the ignored users list
|
||||
for(const douchebag of this.client.user.ignored){
|
||||
if(douchebag.user == user.user){
|
||||
/* Normally I abhor making if statements to set booleans, but this only need to happen when its true
|
||||
Plus I also needed to put the break statement somewhere
|
||||
The fucked thing is the break statement isnt necissary with the if statement, but without it it becomes necissary
|
||||
But it cant be used without the if statement, making the task of reducing linecount for this definition a fucking sisyphean nightmare */
|
||||
ignored = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(ignored){
|
||||
menuMap.set("Unignore", ()=>{this.client.chatBox.transmit(`!unignore ${user.user}`);});
|
||||
}else{
|
||||
menuMap.set("Ignore", ()=>{this.client.chatBox.transmit(`!ignore ${user.user}`);});
|
||||
}
|
||||
|
||||
if(this.client.user.permMap.chan.get("kickUser")){
|
||||
menuMap.set("Kick", ()=>{this.client.chatBox.transmit(`!kick ${user.user}`);});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue