From 1df75ba3ee6278b75d85a60a043af669a8fd6a97 Mon Sep 17 00:00:00 2001 From: Swino4ka Date: Wed, 17 Apr 2024 18:19:57 +0200 Subject: [PATCH] Fixed chat symbols bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Короче баг был, который при отсылании миллиарда символов чат схлопывал. Бл, Рафаелло постоянно просил переделывать, наконец то сделал то, что он принял и залил, всем спасибо за внимание --- luckydiamond/src/components/ChatComponent.vue | 102 +++++++++++++----- .../src/pages/games-pages/CrashgamePage.vue | 11 +- 2 files changed, 75 insertions(+), 38 deletions(-) diff --git a/luckydiamond/src/components/ChatComponent.vue b/luckydiamond/src/components/ChatComponent.vue index 769ca9d..60a4051 100644 --- a/luckydiamond/src/components/ChatComponent.vue +++ b/luckydiamond/src/components/ChatComponent.vue @@ -69,14 +69,37 @@ export default { return msg.msg.includes(GetCookie("SpUserName")); }, ClaimDatamsg(msg) { - const now = Date.now(); - if (!this.lastMsgTime || now - this.lastMsgTime >= 1000) { - SendMessageToChat(msg[0]); - this.lastMsgTime = now; - } else { - alert("Вы не можете отправлять сообщения так часто"); - } - }, + const now = Date.now(); + if (!this.lastMsgTime || now - this.lastMsgTime >= 1000) { + const processedMsg = this.processMessage(msg[0]); + + SendMessageToChat(processedMsg); + 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() { // Mute the chat by disabling the event listener for incoming messages. this.eventBus.$off("dataChat"); @@ -110,29 +133,52 @@ export default { }); }, created() { - GetChatHistory().then((response) => { - if (response && response.length) { - response.forEach((element) => { - let imageUrl = - "https://avatar.spworlds.ru/face/55/" + element.userName; + GetChatHistory().then((response) => { + if (response && response.length) { + response.forEach((element) => { + let imageUrl = + "https://avatar.spworlds.ru/face/55/" + element.userName; - const MsgUser = { - id: this.id + 1, - msg: element.message, - username: element.userName, - icon: imageUrl, - }; + const processedMsg = this.processMessage(element.message); // Process the message - if (MsgUser.username === "🛠️ System") { - MsgUser.icon = "https://avatar.spworlds.ru/face/55/CONSOLE"; - } + const MsgUser = { + id: this.id + 1, + msg: processedMsg, // Use the processed message + username: element.userName, + icon: imageUrl, + }; - this.array.push(MsgUser); - }); - this.ScrollToBottom(); - } - }); - }, + if (MsgUser.username === "🛠️ System") { + MsgUser.icon = "https://avatar.spworlds.ru/face/55/CONSOLE"; + } + + 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(""); +}, }; diff --git a/luckydiamond/src/pages/games-pages/CrashgamePage.vue b/luckydiamond/src/pages/games-pages/CrashgamePage.vue index 4c2b151..7f9e077 100644 --- a/luckydiamond/src/pages/games-pages/CrashgamePage.vue +++ b/luckydiamond/src/pages/games-pages/CrashgamePage.vue @@ -61,7 +61,7 @@
-

{{ game.winX }}

+

@@ -121,7 +121,6 @@ export default { components: { HeaderComponent, AsideBarComponent, ChatComponent, CrashGraphComponent }, data() { return { - winX, SaperNumbers, clickedBtn: null, 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"], async created() { this.CHistory = await CrashHistory();