add votekiss
This commit is contained in:
parent
048af96a19
commit
92860f1ae6
2 changed files with 50 additions and 2 deletions
|
@ -184,6 +184,16 @@ const setupChatboxEvents = (socket) => {
|
|||
);
|
||||
handled = true;
|
||||
break;
|
||||
case "/votekiss":
|
||||
printChatMessage(
|
||||
"vote-kiss",
|
||||
"/votekiss",
|
||||
"b57fdc",
|
||||
document.createTextNode("you voted to kiss " + args)
|
||||
);
|
||||
handled = false;
|
||||
// we also handle this on receive
|
||||
break;
|
||||
case "/help":
|
||||
const helpMessageContent = document.createElement("span");
|
||||
helpMessageContent.innerHTML =
|
||||
|
@ -191,7 +201,8 @@ const setupChatboxEvents = (socket) => {
|
|||
" <code>/help</code> - display this help message<br>" +
|
||||
" <code>/ping [message]</code> - ping all viewers<br>" +
|
||||
" <code>/sync</code> - resyncs you with other viewers<br>" +
|
||||
" <code>/shrug</code> - appends ¯\\_(ツ)_/¯ to your message";
|
||||
" <code>/shrug</code> - appends ¯\\_(ツ)_/¯ to your message" +
|
||||
" <code>/votekiss</code> - like votekick but gay";
|
||||
|
||||
printChatMessage(
|
||||
"command-message",
|
||||
|
@ -327,6 +338,32 @@ const formatTime = (ms) => {
|
|||
}:${seconds < 10 ? "0" + seconds : seconds}`;
|
||||
};
|
||||
|
||||
let kisses = {};
|
||||
function handleClientCommand(content, user) {
|
||||
let handled = false;
|
||||
if (content.startsWith("/")) {
|
||||
const command = content.toLowerCase().match(/^\/\S+/)[0];
|
||||
const args = content.slice(command.length).trim();
|
||||
switch (command) {
|
||||
case "/votekiss":
|
||||
kisses[args] = kisses[args] || {};
|
||||
kisses[args][user] = true;
|
||||
if (Object.keys(kisses[args]).length > 3) {
|
||||
printChatMessage(
|
||||
"user-kissed",
|
||||
args,
|
||||
"ff6094",
|
||||
document.createTextNode("was kissed 💋")
|
||||
);
|
||||
kisses[args] = {};
|
||||
}
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
export const logEventToChat = async (event) => {
|
||||
if (checkDebounce(event)) {
|
||||
return;
|
||||
|
@ -349,12 +386,15 @@ export const logEventToChat = async (event) => {
|
|||
event.colour,
|
||||
document.createTextNode("left")
|
||||
);
|
||||
for(let kissed in kisses) delete kisses[kissed][user]
|
||||
break;
|
||||
}
|
||||
case "ChatMessage": {
|
||||
const messageContent = document.createElement("span");
|
||||
messageContent.classList.add("message-content");
|
||||
if (handleClientCommand(event.data, event.user)) break;
|
||||
messageContent.append(...(await emojify(event.data)));
|
||||
|
||||
printChatMessage(
|
||||
"chat-message",
|
||||
event.user,
|
||||
|
@ -433,7 +473,10 @@ const beep = () => {
|
|||
oscillator.stop(context.currentTime + 0.22);
|
||||
};
|
||||
|
||||
let viewers = [];
|
||||
|
||||
export const updateViewerList = (viewers) => {
|
||||
viewers = _viewers;
|
||||
const listContainer = document.querySelector("#viewer-list");
|
||||
|
||||
// empty out the current list
|
||||
|
|
|
@ -188,10 +188,15 @@ button.small-button {
|
|||
|
||||
.chat-message.user-join,
|
||||
.chat-message.user-leave,
|
||||
.chat-message.ping {
|
||||
.chat-message.ping,
|
||||
.chat-message.user-kissed {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.chat-message.user-kissed {
|
||||
color: #ff6094;
|
||||
}
|
||||
|
||||
.chat-message.set-time,
|
||||
.chat-message.set-playing {
|
||||
font-style: italic;
|
||||
|
|
Loading…
Reference in a new issue