Fixed chat symbols bug

Короче баг был, который при отсылании миллиарда символов чат схлопывал.
Бл, Рафаелло постоянно просил переделывать, наконец то сделал то, что он принял и залил, всем спасибо за внимание
This commit is contained in:
Swino4ka
2024-04-17 18:19:57 +02:00
parent 327dd6c7e9
commit 1df75ba3ee
2 changed files with 75 additions and 38 deletions

View File

@@ -69,14 +69,37 @@ export default {
return msg.msg.includes(GetCookie("SpUserName")); return msg.msg.includes(GetCookie("SpUserName"));
}, },
ClaimDatamsg(msg) { ClaimDatamsg(msg) {
const now = Date.now(); const now = Date.now();
if (!this.lastMsgTime || now - this.lastMsgTime >= 1000) { if (!this.lastMsgTime || now - this.lastMsgTime >= 1000) {
SendMessageToChat(msg[0]); const processedMsg = this.processMessage(msg[0]);
this.lastMsgTime = now;
} else { SendMessageToChat(processedMsg);
alert("Вы не можете отправлять сообщения так часто"); this.lastMsgTime = now;
} } else {
}, alert("Вы не можете отправлять сообщения так часто");
}
},
processMessage(message) {
const maxLength = 5; // Тут макс допустимых символов писать
const processedMessage = [];
let currentSymbol = "";
let count = 0;
for (let i = 0; i < message.length; i++) {
if (message[i] === currentSymbol) {
count++;
} else {
currentSymbol = message[i];
count = 1;
}
if (count <= maxLength) {
processedMessage.push(message[i]);
}
}
return processedMessage.join("");
},
muteChat() { muteChat() {
// Mute the chat by disabling the event listener for incoming messages. // Mute the chat by disabling the event listener for incoming messages.
this.eventBus.$off("dataChat"); this.eventBus.$off("dataChat");
@@ -110,29 +133,52 @@ export default {
}); });
}, },
created() { created() {
GetChatHistory().then((response) => { GetChatHistory().then((response) => {
if (response && response.length) { if (response && response.length) {
response.forEach((element) => { response.forEach((element) => {
let imageUrl = let imageUrl =
"https://avatar.spworlds.ru/face/55/" + element.userName; "https://avatar.spworlds.ru/face/55/" + element.userName;
const MsgUser = { const processedMsg = this.processMessage(element.message); // Process the message
id: this.id + 1,
msg: element.message,
username: element.userName,
icon: imageUrl,
};
if (MsgUser.username === "🛠️ System") { const MsgUser = {
MsgUser.icon = "https://avatar.spworlds.ru/face/55/CONSOLE"; id: this.id + 1,
} msg: processedMsg, // Use the processed message
username: element.userName,
icon: imageUrl,
};
this.array.push(MsgUser); if (MsgUser.username === "🛠️ System") {
}); MsgUser.icon = "https://avatar.spworlds.ru/face/55/CONSOLE";
this.ScrollToBottom(); }
}
}); this.array.push(MsgUser);
}, });
this.ScrollToBottom();
}
});
},
processMessage(message) {
const maxLength = 5; // Тут макс допустимых символов писать
const processedMessage = [];
let currentSymbol = "";
let count = 0;
for (let i = 0; i < message.length; i++) {
if (message[i] === currentSymbol) {
count++;
} else {
currentSymbol = message[i];
count = 1;
}
if (count <= maxLength) {
processedMessage.push(message[i]);
}
}
return processedMessage.join("");
},
}; };
</script> </script>

View File

@@ -61,7 +61,7 @@
<section class="crash-game__players" v-if="crashObject && crashObject.Players"> <section class="crash-game__players" v-if="crashObject && crashObject.Players">
<div class="crash-game-players__content"> <div class="crash-game-players__content">
<div class="crash__history"> <div class="crash__history">
<div class="crash-history__component"> <h2>{{ game.winX }}</h2> </div> <div class="crash-history__component"> <h2></h2> </div>
<div class="crash-history__component"></div> <div class="crash-history__component"></div>
<div class="crash-history__component"></div> <div class="crash-history__component"></div>
<div class="crash-history__component"></div> <div class="crash-history__component"></div>
@@ -121,7 +121,6 @@ export default {
components: { HeaderComponent, AsideBarComponent, ChatComponent, CrashGraphComponent }, components: { HeaderComponent, AsideBarComponent, ChatComponent, CrashGraphComponent },
data() { data() {
return { return {
winX,
SaperNumbers, SaperNumbers,
clickedBtn: null, clickedBtn: null,
ErrorClick: false, ErrorClick: false,
@@ -242,14 +241,6 @@ export default {
} }
}, },
}, },
async created() {
if (GetCookie('AUTHTOKEN') && GetCookie('SearchToken')) {
await GetCurrentMoney(GetCookie('AUTHTOKEN'), GetCookie('SearchToken'))
.then((response) => {
this.balance = response.currentMoney
})
}
},
props: ["payments"], props: ["payments"],
async created() { async created() {
this.CHistory = await CrashHistory(); this.CHistory = await CrashHistory();