[Patch] Chat Filter

Hello everybody,

I’m introducing to you my latest project: the Chat & Anti-Channel-Flood Filter!


[ul][li]Database table chat_filter where you put bad words and add a punishment (bitmask ID).[/li]
[li]Once a player says something in a PUBLIC CHANNEL and the message contains a word you put into the database table, the word is replaced by *'s based on the length of the bad word.[/li]
[li]All messages are converted into lower case so you won’t have to put various ways, like ‘FUCK’, ‘FuCk’, ‘fuck’ - just ‘fuck’ is enough.[/li]
[li]When you choose to freeze or stun the sender/player for using a word and this player logs out during his punishment, the remaining time the sender should be punished will be saved to the database and pulled back in when the player logs back in, making the punishment continue after he logged out.[/li]
[li]When frozen, muted or stunned they will be informed on how long they were punished in minutes and seconds.[/li]
[li]When a message is sent in a public chat channel, it will be added to a vector that can contain up to 50 (change in enums if you want) messages max. If the message you just sent to a channel is in the vector and the sender’s GUID is you, the message won’t be displayed. This means you can’t say the same thing in channels twice within the time it takes the players to send 50 messages in a channel.[/li]
[li]When you want to add new words to the chat_filter table, a simple ‘.reload chat_filter’ in-game makes them instantly active in-game. No relogs or whatsoever are required![/li]
[li]When saying a ‘bad word’, the player gets an one-second stun just so they know they shouldn’t do that. Pretty much to wake them up.[/li]
[li]Kicks are delayed by three seconds so players can read the message saying they got kicked for using a ‘bad word’.[/li]

[SIZE=24px]Source code:[/SIZE]

Chat Filter Diff — Gist

Chat Filter PlayerScript — Gist - This new file won’t show up in the diff for some reason, so apply it manually.

Chat Filter SQL — Gist

[SIZE=24px]List of punishments (bitmask)[/SIZE]


I don’t want anyone to share this outside of the TrinityCore forums. No stupid AC-Web-or-whatever-shitty-forum posts about this. Thank you.




This looks pretty cool. Maybe I can teach myself to watch my language on my server. /emoticons/default_wink.png

Hehe, go ahead and pester your wife that way by filtering out words like ‘and’ and not letting her know (iirc she plays with you). x)

On a more serious note, I’d appreciate any type of testing! Couldn’t find any bugs myself. And I’m also wondering how much of a latency difference this will cause for players on a pretty big server.

Nice ! /emoticons/default_wink.png

I like this

//! If player is frozen or stunned by the chat filter system because

//! they used ‘bad words’ and logout during their punishment, the

//! remaining time they should be frozen or stunned will be saved

//! into a database column and pulled back in on logout.

Now that could be funny and yet end in divorce. /emoticons/default_tongue.png

“Bleep, I’m getting killed” [stun] “Bleep, bleep, bleep, I can’t move!!!” [stun] “Bleep, I can’t move and I’m dead” [stunned corpse at the graveyard] /emoticons/default_wink.png

Now I really want to try it. /emoticons/default_cool.png

Yea my wife would find a creative place to insert my keyboard into my body if I did that to her

This is really nice. Gonna provide some feedback after testing it

IMHO adding 2 new columns to characters table is a bit hardcore.

Yeah, I guess I could make a new table for this. I wrote that part (saving timers on logout) when it was 3.30 AM and for some reason my thoughts were telling me it wouldn’t be possible because only characters table has player GUIDs, while that’s just a matter of creating a new table. Will make a little update in a while.

Thanks for the positive feedback guys!


[ul][li]Updated the SQL, it no longer has columns in chat_filter that shouldn’t be there (forgot to remove).[/li]
[li]Freeze- and Stuntimers are now stored in an unique table (characters.chat_filter_storage) instead of the characters table.[/li]
[li]Moved chat_filter into characters database.[/li]
[li]Bad words are no longer pulled from WorldDatabase by default… >_>[/li]

Timers are put back into characters table - for some reason that’s the only thing that works. New tables just tend to fuck up.

Discover, why don’t you put the tables on realm database and make it available to all realms? That will save some space and spare the user to duplicate the work for all realms!

Also, it is interesting to see a user getting stun for 10 minutes and realm 1, he log out and goes to realm 2 and he continues stunned. /emoticons/default_smile.png

This is the kind of custom code that would be cool to add to the main branch, disabled by default, with a config option to turn it on.

I could see a very valid use for this if I want people to watch their language so I can let my little nephew run around in the game.

That’s also what I suggested in the dev channel, just not every developer agreed to it. The code isn’t too good, they say.

Maybe if you just replace the words and cut all the bans and freezes. It sounds a bit too custom.

How is something that is completely custom even able to sound ‘too custom’? The whole point of it is to be custom. If it would ever get into official reposority, it would be handled by a shitload of configs anyway, so no worries about that.

Adding more restricted words can be blizzlike… i guess.

I don’t see how you find any relation between this and the word ‘blizzlike’.

Point of this is not be blizzlike or anything, it’s to provide a tool for admins that want to improve the game experience on their servers.

Blizzlike applies to content that comes from Blizzard.

Do not forget that Trinity is not Mangos. Mangos would only allow blizzlike code in their repository, trinitycore accepts a much wider range of modifications.

Trinitycore wants to improve end user experience.

Well maybe they have some some suggestions to improve the code to make it acceptable.

nice Discover


pls help me to change convertedMsg :

i want to change Word to One Word Specified…

for Example When Type test and this Word Converted to **** …

i want Convert all Word to Word Specified… . and When type test , this Word Converted to wow .

pls help me