SpiTik Posted January 7, 2018 Report Posted January 7, 2018 Im found only this but I do not know how to use it when I have it client.on('friendMessage', (steamid, message) please Help Thanks.2 message per sec or remove setInterval(() => { for (let i = 0; i < Object.keys(userMsgs).length; i++) { if (userMsgs[Object.keys(userMsgs)] > 2) { client.chatMessage(Object.keys(userMsgs), "You have been removed for spamming. Another offense will get you blocked."); client.removeFriend(Object.keys(userMsgs)); } } userMsgs = {}; }, 1000); Quote
Dr. McKay Posted January 7, 2018 Report Posted January 7, 2018 In your if you probably want to check .length. Quote
Vanilla Posted January 12, 2018 Report Posted January 12, 2018 (edited) Not really an answer, but here's a small code I use on my bot to prevent chat spam.It will block a person who send same messages every 2 second. var antispam; var markedSteamID; function spamtimer() { //when called, it will reset antispam = 0; markedSteamID = 0; } setInterval(spamtimer, 2000); //call spamtimer function every 2 sec //.. your code here client.on("friendMessage", function(senderID, message) { //anti spam if (senderID == admin){ //Ignore if chat from admin } else if ((antispam == message) && (markedSteamID == senderID.getSteamID64())) { client.chatMessage(senderID, "I caught you spamming"); //do something, like block that person or something } //.. your code here.. to respond chat antispam = message; //bot will record the message, will reset every 2 sec markedSteamID = senderID.getSteamID64(); //bot will record SteamID of sender, will reset every 2 sec }); Edited January 12, 2018 by Vanilla SpiTik 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.