-
Notifications
You must be signed in to change notification settings - Fork 11
No rude words...
Want to check if the text a player has typed includes any rude words?
This code can be put in a function, with a single parameter, "str" and to return a Boolean, true if a naughty word is detected, false otherwise.
if (game.censorlist = null) {
list = Split("ass;asshole;shit;crap", ";")
game.censorlist = NewStringList()
foreach (s, list) {
s = Replace(LCase(s), "i", "(i|1|!)")
s = Replace(s, "l", "(l|1|!)")
s = Replace(s, "o", "(o|0)")
s = Replace(s, "a", "(a|@)")
s = Replace(s, "s", "(s|\\$)")
s = "( |^|\\-)" + s + "( |$|\\-)"
list add (game.censorlist, s)
}
}
str = LCase(str)
foreach (s, game.censorlist) {
msg (str + "/" + s)
if (IsRegexMatch(s, str)) {
return (true)
}
}
return (false)
You can add any words you want to catch to the list in the second line (I do not want to get this page flagged for bad content, so I have just added a very small selection there). And what counts as a rude word can be contentious; "fag", for example, which is slang for cigarette in the UK. Exactly what words you allow is your decision.
Note that it will catch "sh1t", "@$$" and stuff like that too (and is case insensitive). However, it will only spot whole words so rude words embedded in a long word will not get caught (but then, it should not catch "associate" or "scunthorpe").