Skip to content
samuri51 edited this page Jan 11, 2013 · 1 revision

this is a basic curse filter that you can choose to add to the bot if you want to.

global.swearWords = /\b(fuck|shit|ass)\b/i; //put swear words in here(separete swear words with | do not touch anything else
global.swearArray = []; //do not touch



//starts up when bot first enters the room
bot.on('roomChanged', function (data)
{
    for (var example1 = 0; example1 < userIds.length; example1++)
    {
        swearArray[userIds[example1]] = { //set everyones swear counter to zero
            counter: 0 //when the bot enters the room
        };
    }
});



//starts up when a new person joins the room
bot.on('registered', function (data)
{
    swearArray[data.user[0].userid] = { //set their swear counter to zero
        counter: 0 //when they enter the room
    };
});



//starts up when a user leaves the room
bot.on('deregistered', function (data)
{
    delete swearArray[data.user[0].userid]; //delete their swear counter when they leave the room
});



bot.on('speak', function (data)
{
    if (data.text.match(swearWords)) //checks to see if swear words are being used
    {
        if (data.userid != USERID) //bot does not boot itself
        {
            ++swearArray[data.userid].counter; //adds one to their counter
            if (swearArray[data.userid].counter == 1)
            { //first message
                bot.getProfile(data.userid, function (data3)
                {
                    bot.speak('@' + data3.name + ' cussing is not allowed in this room, further violations will result in a boot/ban');
                });
            }
            else if (swearArray[data.userid].counter >= 2) //two or more matches, person gets booted
            {
                bot.boot(data.userid, 'further cussing violations will result in a ban');
            }
        }
    }
});
Clone this wiki locally