How to Create a Language and CAPS Filter

Re: How to Create a Language and CAPS Filter

Postby LogicaLucidity » 10 Feb 2013, 19:10

Ultima brought up a good addition to the code on another thread...

Ultima wrote:You can add a counter here:

Code: Select all
msg = msg.Replace(badWord, "[ %cRemoved %f]" + Server.DefaultColor);


If that is triggerd 3 times then kick him.



Ultima, if you or anyone would be so kind to assist in creating this counter and posting the altered code I would appreciate it.

Dzienny, if you would also consider adding this new feature to the finished product that would be great as well.

Thank you,

Logic
- [Logic] Lava Survival -
User avatar
LogicaLucidity
 
Posts: 104
Joined: 17 Oct 2011, 09:36

Re: How to Create a Language and CAPS Filter

Postby Conor » 12 Feb 2013, 00:10

This would keep a counter on them until the server restarts. You could make it until they disconnect by adding a timer to check if they leave the server and then remove them from the lists, but I'm too lazy to do that. This would be a lot easier to code in source as you can add a Player.bool. But anyway, this is how I would do it... probably not very efficient or what not but hopefully this would work and help you.

Under the line of code you have above, add:
Code: Select all
checkWarningStatus(p);


Underneath the method:
Code: Select all
public override void Use(Player p, string message)
{
  // Content
}


Add this code below that method (below the closing curly bracket of that method):

Code: Select all
public static List<Player> warnedOnce = new List<Player>();
public static List<Player> warnedTwice = new List<Player>();

public void checkWarningStatus(Player p)
{
   if (warnedOnce.Contains(p))
   {
       Player.SendMessage(p, "This is your second warning for inappropriate chat. You will be kicked if you continue.");
       warnedOnce.Remove(p);
       warnedTwice.Add(p);
   }
   else if (warnedTwice.Contains(p))
   {
      warnedTwice.Remove(p);
      p.Kick("You were kicked by the server for inappropriate chat.");
   }
   else
   {
      warnedOnce.Add(p);
      Player.SendMessage(p, "You have been warned for inappropriate chat. You will be kicked if you continue.");
   }
}
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: How to Create a Language and CAPS Filter

Postby dzienny » 12 Feb 2013, 00:28

Conor wrote:This would be a lot easier to code in source as you can add a Player.bool.


Actually, you can add bool or any other type of variable or class to the Player object. I haven't mentioned it anywhere, but there is a special way to do it. Player object contains ExtraData object, which is of type Dictionary<string, object>. It was created to let you add to the Player as many variables as you need. In order to do it you have to:
1. Think up some key of type string. And, it would be good to save it as a constant value.
2. Add this key with the respective object of any type to the ExtraData.
3. Retrieve and edit the value later as needed.
Here's an example:
Code: Select all
public const string KeySomeInt = "SomeInt";

public void IncreaseWarningsAndKick(Player p)
{
    if (!p.ExtraData.ContainsKey(KeySomeInt))
    {
        // Saves int value of 1 to ExtraData under "SomeInt" key.
        p.ExtraData.Add(KeySomeInt, 1);
    }
    else
    {
        // Casts the value that is stored under "SomeInt" key to int
        // and increases it by one and stores in newWarnCount variable.
        int newWarnCount = (int) p.ExtraData[KeySomeInt] + 1;
        if (newWarnCount > 3)
        {
            p.Kick("&cKick: Too many warnings.");
            return;
        }
        p.ExtraData[KeySomeInt] = newWarnCount;
    }
}


I use this method more and more often. In many cases it seems to be a better and cleaner solution than adding another variables to the Player class.

Anyway, the example you published is very clever. It does the job without using Player's variables. In programming there are many different ways to achieve exactly the same result and it's one of the things that make programming very interesting.
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: How to Create a Language and CAPS Filter

Postby toystory_justin » 12 Feb 2013, 09:56

This is what I found this far, and finally, someone posts this warn-kick, Thanks for the participators on this post :D
toystory_justin
 
Posts: 224
Joined: 11 Nov 2012, 07:12
Location: On a dark place

Re: How to Create a Language and CAPS Filter

Postby toystory_justin » 12 Feb 2013, 10:05

Where do I add this? In below what method?
toystory_justin
 
Posts: 224
Joined: 11 Nov 2012, 07:12
Location: On a dark place

Re: How to Create a Language and CAPS Filter

Postby Conor » 12 Feb 2013, 18:53

Oh wow, I never knew about that dictionary in the Player class, that is awesome and could help a lot ! :)

I will use it in the future for sure, thank you Dzienny for notifying us and giving an example.
Conor (Conanza121)
User avatar
Conor
Coder
 
Posts: 390
Joined: 10 Oct 2012, 21:36
Location: @21Conor

Re: How to Create a Language and CAPS Filter

Postby Ultima » 13 Feb 2013, 07:22

I will post my final version here tonight.
It warns + auto-kicks to.

They can rejoin and the counter will reset winhout restarting the server.

I am using the p.realname btw :mrgreen: was not being used anyway.
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: How to Create a Language and CAPS Filter

Postby LogicaLucidity » 13 Feb 2013, 08:00

Thank you for the update Dzienny.

The auto kick is very nice.

For those who are looking for the easy paste list of my words without the punctuation...Here they are...

Just copy and paste them into your 'badwords' text file in your text folder.

Code: Select all
4r5e
5h1t
5hit
a55
ar5e
arrse
arse
ass
asshole
b!tch
b00bs
b17ch
b1tch
ballbag
balls
ballsack
bastard
basterd
basturd
beastial
beastiality
bestial
bestiality
bi+ch
biatch
biotch
bitch
blowjob
blowjob
blowjobs
bollock
bollok
boner
boob
boobs
booobs
boooobs
booooobs
boooooobs
booooooobs
boooooooobs
booooooooobs
boooooooooobs
booooooooooobs
boooooooooooobs
booooooooooooobs
boooooooooooooobs
booooooooooooooobs
boooooooooooooooobs
booooooooooooooooobs
boooooooooooooooooobs
breasts
buceta
bugger
c0ck
carpetmuncher
cawk
chink
cipa
cl1t
clit
clitoris
clits
cnut
cock
cokmuncher
coksucka
cox
crap
cum
cumm
cumshot
cunilingus
cunillingus
cunnilingus
cunt
cuntlick
cuntlicker
cuntlicking
cyberfuc
d1ck
dick
dickhead
dildo
dlck
donkeyribber
doosh
duche
dumbass
dumass
dyke
ejaculate
ejaculated
ejaculates
ejaculating
ejaculatings
ejaculation
ejakulate
fuck
fucker
fag
fagging
faggitt
faggot
faggs
fagot
fagots
fags
fanny
fannyflaps
fannyfucker
fanyy
fatass
fcuk
fcuker
fcuking
feck
fecker
felching
fellate
fellatio
fingerfuck
fingerfucked
fingerfucker
fingerfuckers
fingerfucking
fingerfucks
fistfuck
fistfucked
fistfucker
fistfuckers
fistfucking
fistfuckings
fistfucks
flange
fook
fooker
fuck
fuuck
fuuuck
fuuuuck
fuuuuuck
fuuuuuuck
fuuuuuuuck
fuuuuuuuuck
fuuuuuuuuuck
fuuuuuuuuuuck
fuuuuuuuuuuuck
fuuuuuuuuuuuuck
fuuuuuuuuuuuuuck
fuuuuuuuuuuuuuuck
fuuuuuuuuuuuuuuuck
fuuuuuuuuuuuuuuuuck
fuuuuuuuuuuuuuuuuuck
fuuuuuuuuuuuuuuuuuuck
fucka
fucked
fucker
fuckers
fuckhead
fuckheads
fuckin
fucking
fuckings
fuckingshitmotherfucker
fuckme
fucks
fuckwhit
fuckwit
fudgepacker
fudgepacker
fuhk
fuk
fuker
fukker
fukkin
fuks
fukwhit
fukwit
fux
fux0r
f_u_c_k
gangbang
gangbanged
gangbangs
gaylord
gaysex
goatse
god-dam
goddam
goddam
god-damned
goddamn
goddamn
goddamned
goddamned
hardcoresex
homo
horniest
horny
hotsex
idiot
1diot
id1ot
1d1ot
jack-off
jackoff
jerk-off
jism
jiz
jizm
jizz
kawk
knob
knobead
knobed
knobend
knobhead
knobjocky
knobjokey
kock
kondum
kondums
kum
kummer
kumming
kums
kunilingus
laag
laaag
laaaag
laaaaag
laaaaaag
laaaaaaag
laaaaaaaag
laaaaaaaaag
laaaaaaaaaag
laaaaaaaaaaag
laaaaaaaaaaaag
laaaaaaaaaaaaag
laaaaaaaaaaaaaag
laaaaaaaaaaaaaaag
laaaaaaaaaaaaaaaag
laaaaaaaaaaaaaaaaag
laaaaaaaaaaaaaaaaaag
l3i+ch
l3itch
labia
m0f0
m0fo
m45terbate
ma5terb8
ma5terbate
masochist
master-bate
masterb8
masterbat*
masterbat3
masterbate
masterbation
masterbations
masturbate
mo-fo
mof0
mofo
moron
mothafuck
mothafucka
mothafuckas
mothafuckaz
mothafucked
mothafucker
mothafuckers
mothafuckin
mothafucking
mothafuckings
mothafucks
motherfucker
motherfuck
motherfucked
motherfucker
motherfuckers
motherfuckin
motherfucking
motherfuckings
motherfuckka
motherfucks
muthafecker
muthafuckker
muther
mutherfucker
n1gga
n1gger
nazi
nigg3r
nigg4h
nigga
niggah
niggas
niggaz
nigger
niggers
nobjokey
nobhead
nobjocky
nobjokey
numbnuts
nutsack
orgasim
orgasims
orgasm
orgasms
p0rn
pecker
penis
penisfucker
phonesex
phuck
phuk
phuked
phuking
phukked
phukking
phuks
phuq
pigfucker
pimpis
piss
pissed
pisser
pissers
pissflaps
pissin
pissing
pissoff
porn
porno
pornography
pornos
prick
pricks
pron
pube
pusse
pussi
pussies
pussy
pussys
rectum
retard
rimjaw
rimming
s ex
s e x
sex
sexx
sexxx
shit
shit
s.o.b.
schlong
screwing
scroat
scrote
scrotum
sh!+
sh!t
sh1t
shag
shagger
shaggin
shemale
shi+
shit
shiit
shiiit
shiiiit
shiiiiit
shiiiiiit
shiiiiiiit
shiiiiiiiit
shiiiiiiiiit
shiiiiiiiiiit
shitdick
shite
shited
shitey
shitfuck
shitfull
shithead
shiting
shitings
shits
shitted
shitter
shitters
shitting
shittings
shitty
skank
skullfuck
skullfuck
slut
sluts
smegma
smut
snatch
son-of-a-bitch
sonofabitch
suck
suckit
suckit
sucks
sux
s_h_i_t
t1tt1e5
t1tties
teets
testical
testicle
titfuck
tittie5
tittiefucker
titties
tittyfuck
tittywank
titwank
tosser
tw4t
twat
twathead
twatty
twunt
twunter
vagina
vulva
w00se
wang
wank
wanker
wanky
whoar
xrated
xxx


- Logic
- [Logic] Lava Survival -
User avatar
LogicaLucidity
 
Posts: 104
Joined: 17 Oct 2011, 09:36

Re: How to Create a Language and CAPS Filter

Postby Ultima » 13 Feb 2013, 19:31

Since the software now contains chat filters i suggest to use those.

If a badword is "ass", does the detector see it in a word like "badass" or "a.ss?"

It's funny to see somethings back in the software that i made like %f[%cRemoved%f] :mrgreen:
User avatar
Ultima
 
Posts: 953
Joined: 19 Aug 2011, 23:45

Re: How to Create a Language and CAPS Filter

Postby LogicaLucidity » 13 Feb 2013, 23:18

Here is an example:

Lets say you have ass in you list of words.

If your detection level is low then 'ass' will be blocked but 'glass' will not.
Only the exact word will trigger the filter is on low.

If your detection level is High then 'ass' ... 'glass' ... 'bass' ... 'derpassderp' will be blocked.
Any word containing the word will trigger the filter.
In this case, you will need to add non bad words that might get triggered to the 'white list'.

In my case, I have added 'ass' and 'balls' to my list and set the filter on high.
I have also added 'glass' and 'ball' to the white list.

In order for 'a.ss' to get triggered then 'a.ss' has to be in the list.

Also, caps no longer effect whether or not a word is triggered.
Ass ... aSs ... asS ... ASs.... ASS ... aSS ... all trigger the filter if 'ass' is listed.

The options that have been included in the filter tab are amazing.

I hope that helps.

- Logic
- [Logic] Lava Survival -
User avatar
LogicaLucidity
 
Posts: 104
Joined: 17 Oct 2011, 09:36

PreviousNext

Return to How-To

Who is online

Users browsing this forum: No registered users and 4 guests

cron