Barbosik / MultiOgar

An open source Ogar server implementation, written with Node.js.
Other
61 stars 44 forks source link

Censorship for chat? #164

Closed lulzyyy closed 8 years ago

lulzyyy commented 8 years ago

What is needed is the option of censoring chat because a lot of kids play this game and sometimes people use very vulgar language... I added censorship to my public servers on c0nsume.me and I used this https://www.npmjs.com/package/censoring + some validation with regular expressions. May be useful

Barbosik commented 8 years ago

Yeah, I just thinking about it :) Will be added soon

chuushi commented 8 years ago

I used some form of custom censorship for fun. I'll pull up a snippet of my code from my server when I get a chance.

(Or @Barbosik can if he wants.)

chuushi commented 8 years ago

Snippet: (contains vulgar words)

GameServer.prototype.wordFilter = function(words) {
    if (this.wordFilterList.length == 0) {
        return words;
    }
    var out = words;
    var low = words.toLowerCase();
    if (low.indexOf("team") >= 0 && low.indexOf("no") < 0 && low.indexOf("n't") < 0 && low.indexOf("stop") < 0 && low.indexOf("hate") < 0) {
        out = "I HATE TEAMING";
    }
    else {
        // Because regex takes loger to process
        if (low.indexOf("bitch") >= 0)
            out = out.replace(/bitch/ig, "coast");
        if (low.indexOf("fuck") >= 0)
            out = out.replace(/fuck/ig, "ahhh");
        if (low.indexOf("shit") >= 0 || low.indexOf("crap") >= 0)
            out = out.replace(/shit|crap/ig, "gold");
        if (low.indexOf("damn") >= 0)
            out = out.replace(/damn/ig, "wall");
        if (low.indexOf("dick") >= 0)
            out = out.replace(/dick/ig, "ohhh");
    }
    return out;
}
BaumanDev commented 8 years ago

Seems cool.

Influxx commented 8 years ago

I would do this client-side (receiving end), not server-side.

makandz commented 8 years ago

Well this isn't really an issue but people could easily make scripts to stop the encoding of the words if it was client sided.

Barbosik commented 8 years ago

implemented. You can add censored words into badwords.txt. But do not add large amount of words, because it will leads to lags.