Jump to content
McKay Development

Chat Anti Spam Help


Recommended Posts

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.");
    userMsgs = {};


}, 1000);
Link to comment
Share on other sites

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 by Vanilla
Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...