haxball / haxball-issues

115 stars 43 forks source link

about ban #1589

Closed ghost closed 1 year ago

ghost commented 2 years ago

I want a code that automatically bans ppl with bad words in their username when they enter the room.

can u help me ?

thenorthstar commented 2 years ago

I want a code that automatically bans ppl with bad words in their username when they enter the room.

can u help me ?

@mydestiny185 You can use the following code. The bad words here are a collection from my own scripts btw:

var badwords = [/[a4@][s$5][s$5]h[o0][l1][e€]+/,/[bß][a4@]rm[iy7]+/,/[bß][a4@][s$5][t₺][a4@]rd+/,/[bß][ıi1][t₺][cç¢]h+/,/[c¢]un[t₺]+/,/f[uü][cç¢]k+/,/[l1]m[a4@][o0]+/,/[l1]mf[a4@][o0]+/,/pu[s5$][s5$][y7]+/,/r[e€][t₺][a4@]rd+/,/[s$5][t₺]fu+/,/wh[o0]r[e€]+/,/w[t₺]f+/];

function isBadword(str){
    return badwords.filter(b => str.match(b)).length > 0;
}

room.onPlayerJoin = function(player){
    if(isBadword(player.name) == true){
    room.kickPlayer(player.id,"You cannot join this room with such a name.",true);
    }
}
ghost commented 2 years ago

@thenorthstar I wasn't able to run this code. Is there any other alternative?

thenorthstar commented 2 years ago

@thenorthstar I wasn't able to run this code. Is there any other alternative?

@mydestiny185 But why? Isn't it so simple code to run?