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

@@ -71,11 +71,34 @@ export default {
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]);
SendMessageToChat(processedMsg);
this.lastMsgTime = now; this.lastMsgTime = now;
} else { } else {
alert("Вы не можете отправлять сообщения так часто"); 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.
@@ -116,9 +139,11 @@ export default {
let imageUrl = let imageUrl =
"https://avatar.spworlds.ru/face/55/" + element.userName; "https://avatar.spworlds.ru/face/55/" + element.userName;
const processedMsg = this.processMessage(element.message); // Process the message
const MsgUser = { const MsgUser = {
id: this.id + 1, id: this.id + 1,
msg: element.message, msg: processedMsg, // Use the processed message
username: element.userName, username: element.userName,
icon: imageUrl, icon: imageUrl,
}; };
@@ -133,6 +158,27 @@ export default {
} }
}); });
}, },
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();