Issue with Word Filter in SmartFoxServer

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

Moderators: Lapo, Bax

Post Reply
ciaoamigos
Posts: 70
Joined: 05 Sep 2021, 16:57

Issue with Word Filter in SmartFoxServer

Post by ciaoamigos »

Hi everyone,
I'm configuring the Words Filter in SmartFoxServer, but the system does not seem to detect and censor words based on the regex I have added.
Here are the details of my configuration:

Activated: ✅ Yes
Maximum bad words per message: 0
Send warnings: ✅ Yes
Warnings before kicking: 4
Kicks before banning: 2
Kick before banning timeframe: 3 minutes
Duration of banning: 1440 minutes (24 hours)
Custom warning, kicking, and banning messages: Set correctly
Ban mode: NAME
Words file: config/wordsFile.txt
Character to hide bad words: *
Filter mode: BLACKLIST
In the words file, I have added the following regex:

Code: Select all

(?i:08sex)
([f|F][\W]*[u|U][\W]*[c|C][\W]*[k|K][\W]*)

Unfortunately, the filter is not detecting or censoring these words when messages are sent in the chat.

Does anyone have experience with SmartFoxServer's word filter and know if my approach is correct?
Should I modify the regex syntax or adjust the server settings in any way?

Thanks in advance for your help!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issue with Word Filter in SmartFoxServer

Post by Lapo »

Hi,
the first regex seems incorrect and thus will not match the expected word.
The second one should work correctly, catching all combinations of upper/lower cases.

Make sure that every Room that needs word filtering has the relative config flag set. Under AdminTool > ZoneConfigurator > Room > "Use Bad Word Filter". If you're creating Rooms dynamically from Extension code there's an option under the CreateRoomSettings class.

If you want to check the correctness of the regexes you can use this website:
https://regex101.com/

Make sure to switch to "Java 8" before testing.
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
ciaoamigos
Posts: 70
Joined: 05 Sep 2021, 16:57

Re: Issue with Word Filter in SmartFoxServer

Post by ciaoamigos »

I tested the word on regex101.com and it is detected correctly. However, SmartFoxServer does not intercept the string in the public chat.

Could it be that, on the server side, the use of the event:

Code: Select all

addEventHandler(SFSEventType.PUBLIC_MESSAGE, PublicMessageHandler.class);


is causing some issues?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issue with Word Filter in SmartFoxServer

Post by Lapo »

ciaoamigos wrote:I tested the word on regex101.com and it is detected correctly.

Which one of the two expressions are you referring to?

However, SmartFoxServer does not intercept the string in the public chat.

Again which one? You showed two reg. expressions.

Could it be that, on the server side, the use of the event:

Code: Select all

addEventHandler(SFSEventType.PUBLIC_MESSAGE, PublicMessageHandler.class);


No, the filtering happens before.

Did you check that the filter is active in the Room?
Also which "filter mode" is configured? WHITELIST or BLACKLIST?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
stelarfox
Posts: 34
Joined: 06 Aug 2021, 14:33
Location: Argentina, BsAs

Re: Issue with Word Filter in SmartFoxServer

Post by stelarfox »

Hello I have a problem because I read this chat and have a similar problem, I want to store the data to later send to those to people that "got late" into the room. But when I do such the main problem is that the words no longer are filtered.
And As I check up by placing:

Code: Select all

addEventHandler(SFSEventType.PUBLIC_MESSAGE, PublicMessageHandler.class);

I read that the message that arrives to the PublicMessageHandler
is NOT already filtered but for what you said before
No, the filtering happens before.

So I do not get it if happen before why what arrives there is not yet filtered, did you mean the filtering happens after.
And if so is there any way to make it happen before may be some weird configuration?
The only difference with this example is that there I do not send a warning which should not bother should it
And the issue is that the public message reception is ok, the one I store to later give via other method is the wrong one and for what you said should not. Any easy solution for this without having to do everything myself?
stelarfox
Posts: 34
Joined: 06 Aug 2021, 14:33
Location: Argentina, BsAs

Re: Issue with Word Filter in SmartFoxServer

Post by stelarfox »

well i found a way to solve it

Code: Select all

msg=getParentZone().getWordFilter().apply(msg).getMessage();

please let me know how bad it is. or if its correct to do such.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issue with Word Filter in SmartFoxServer

Post by Lapo »

Hi,
I stand corrected. The PUBLIC_MESSAGE event is fired before applying word filters, sorry for the misunderstanding.
I had to go back and double check since this is a bit of an exception among other events. Normally events are fired at the end of the API call but not in this case.

The reason for this is that by having access to the original message an Admin can go back and see what was said in case of banning disputes, or users misbehaving and causing problems to others.

Re-applying the filter as you have suggested is a good solution to your specific problem, if you want the messages to be stored with bad words filtered out.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply