Word Filter kick/ban

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

tpenn
Posts: 95
Joined: 03 Aug 2010, 18:48

Word Filter kick/ban

Postby tpenn » 24 Feb 2011, 14:52

I have a question about using the word filter.

I want to use it, but I really don't want to use SmartFox's system of issuing warnings and bans for using bad words. However, I am not sure how to disable that particular piece of functionality.

While I see no option in the admin tool, the zone.xml does have a <useWarnings> tag under <wordsFilter>. This, however, does not seem to do anything.

Is there a way to turn off the SmartFox warnings and bans? If not, will one be added?

On a separate note, I store my words list in a database rather than a .txt file, and read the expressions in when the server starts. Failing to specify a file generates a FileNotFoundException, although the filter does still appear to function properly. It would be nice if not specifying a file didn't cause an exception.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 24 Feb 2011, 18:29

First of all, the <useWarnings> parameter should be available in the Admin Tool too, but it seems we missed it. We will add it in the next release together with another missing parameter containing the warning message.

Anyway, if <useWarnings> is set to false, the warning are not sent to the client. Kicking and banning can't be disabled, but you can set the "Warnings before kick" and "Kicks before ban" parameters at a very high value.

About the FileNotFoundException, we will take a look. Thank you for pointing out.
Paolo Bax
The SmartFoxServer Team
tpenn
Posts: 95
Joined: 03 Aug 2010, 18:48

Postby tpenn » 24 Feb 2011, 19:46

Thank you much. Makes sense that <useWarnings> disables warnings but doesn't affect kick/ban.

I had set the number of warnings and kicks very high as a workaround; I guess it just became a permanent solution.
falcan
Posts: 44
Joined: 04 Mar 2009, 12:55

Postby falcan » 24 Feb 2011, 21:29

I was just fiddling with word filter customization myself - worth nothing is you can always grab the word filter from a zone and then force it to filter anything it seems :)

Code: Select all

IWordFilter wordFilter = ext.getParentZone().getWordFilter();


I'm using it in my custom zone filter, where the messages arrive unfiltered even if word filter is on(I suppose they get filtered after my custom filter is finished), but I needed to check for filtering before that. So basically, you can "prefilter" like this in your filter:

Code: Select all

if (theRoom.isUseWordsFilter()) {
        message = wordFilter.apply(message, theUser).getMessage();
}       


Maybe there is another way, who knows. Anyway, I can imagine that you can also dynamically load words from a database, if you use the same class, there is one interesting method "addExpression(java.lang.String word)", sounds like it adds something into dictionary, but I didn't try it out :)
tpenn
Posts: 95
Joined: 03 Aug 2010, 18:48

Postby tpenn » 25 Feb 2011, 15:19

Yes, that is basically what I do. I load all my expressions from a database, using addFilter. I've had to replace the standard requests for public and private messages with my own, and apply the filter to the messages as you describe. I also have requests for GMs to add or remove expressions, so we can update the filter realtime without needing to restart the server. It all works really well, other than a minor issue when one expression is a subset of another (it will sometimes filter the smaller one and then not catch the longer, detailed in this post:.http://www.smartfoxserver.com/forums/viewtopic.php?t=10165), but I've been building my expressions to work around that.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 85 guests