Add time check for message sending

This commit is contained in:
Hepatica
2024-01-27 19:49:02 +01:00
parent 0573521e94
commit a0af89cd26

View File

@@ -43,6 +43,7 @@ export default {
return { return {
array: [], array: [],
id: 0, id: 0,
lastMsgTime: null,
}; };
}, },
methods: { methods: {
@@ -53,8 +54,13 @@ export default {
}); });
}, },
ClaimDatamsg(msg) { ClaimDatamsg(msg) {
const now = Date.now();
if (!this.lastMsgTime || now - this.lastMsgTime >= 2000) {
SendMessageToChat(msg[0]); SendMessageToChat(msg[0]);
this.lastMsgTime = now;
} else {
alert("Вы не можете отправлять сообщения чаще, чем раз в 2 секунды.");
}
// if(this.array.length > 7) { // if(this.array.length > 7) {
// this.array.shift() // this.array.shift()
// } // }