BadWords filter extension
BadWords filter extension
Hello. May be this is a common topic, but i haven't found the answer for it, so, gonna ask here.
I'm going to create some extension - my own badword filer.
What steps should be done? I should disable integrated one somehow, right?
I need some help, being new to this. Thanks
I'm going to create some extension - my own badword filer.
What steps should be done? I should disable integrated one somehow, right?
I need some help, being new to this. Thanks
Yeah
So.
I've figured out how to write an extensions in Java (via AbstractExtension).
Now i need to serarch for badwords in internaleventobject every message, and if i've found something forbidden - dispatch it? Then what? Explain please, it'll safe much time
I've figured out how to write an extensions in Java (via AbstractExtension).
Now i need to serarch for badwords in internaleventobject every message, and if i've found something forbidden - dispatch it? Then what? Explain please, it'll safe much time
What you said is pretty much the summary of what you need to do.Now i need to serarch for badwords in internaleventobject every message, and if i've found something forbidden - dispatch it? Then what? Explain please, it'll safe much time
Firstly, you'll need to enable pub message internal event using: zone.setPubMsgInternalEvent(true);
Then when you intercept the message, perform your logic. Filter out bad words, or discard the message and reply with a warning, or whatever suits.
Basically, the code would look like this:
Code: Select all
if (evtName.equals(InternalEventObject.EVENT_PUBLIC_MESSAGE))
{
Room room = (Room) ieo.getObject("room");
User sender = (User) ieo.getObject("user");
String message = (String) ieo.getParam("msg");
String roomId = Integer.toString(room.getId());
String senderId = Integer.toString(sender.getUserId());
String senderName = sender.getName();
//do your logic here
LinkedList<SocketChannel> sendList = room.getChannellList();
helper.dispatchPublicMessage(message, room, sendList);
}Smartfox's forum is my daily newspaper.
Thanks!
Ok, if i consider that the current message contains some bad words, should i warn the user by myself somehow?
Config.xml gives the amuont of allowed swearing, so
And to make it work, i should change config.xml like
<Badwords filter active = "false">
and then load my extension? But it'll work just for choosen zone and badwords filter works for everything
P. S. In addition, is there any chance to make extension work for the whole server, all zones, not just for the one?
Ok, if i consider that the current message contains some bad words, should i warn the user by myself somehow?
Config.xml gives the amuont of allowed swearing, so
Code: Select all
if (isBas(message))
// Do what? Warn, ban, kick? or it's none of my business?
else
helper.dispatchPublicMessage(message, room, sendList);
<Badwords filter active = "false">
and then load my extension? But it'll work just for choosen zone and badwords filter works for everything
P. S. In addition, is there any chance to make extension work for the whole server, all zones, not just for the one?
[url]Ok, if i consider that the current message contains some bad words, should i warn the user by myself somehow?[/url]
Correct.
Correct.
Yes. If you want to implement your own custom bad word filter for every zone, you'll have to add the code for each of your extension. Disabling BadWordsFilter via config.xml will disable it as a whole.And to make it work, i should change config.xml like
<Badwords filter active = "false">
and then load my extension? But it'll work just for choosen zone and badwords filter works for everything
Sorry, this is not possible.In addition, is there any chance to make extension work for the whole server, all zones, not just for the one?
Smartfox's forum is my daily newspaper.
Got you.
Thanks for quick replies, you helped a lot in this question.
My filter works fine... Except private messages, throws an exception NullPointer Exception, when i call despatchPrivateMessage. Any ideas? All variables (msg, room, sender, recipient) aren't null, has been checked.
With public - no problem.
Thanks for quick replies, you helped a lot in this question.
My filter works fine... Except private messages, throws an exception NullPointer Exception, when i call despatchPrivateMessage. Any ideas? All variables (msg, room, sender, recipient) aren't null, has been checked.
With public - no problem.
I've found my bug.
http://www.smartfoxserver.com/docs/doc ... ssage.htm
from that link i thought that for private messages i should write
but actually it must be
Spent two days on it. I should have seen properties for clear, not code for misunderstanding. Have no questions any more, thanks!
http://www.smartfoxserver.com/docs/doc ... ssage.htm
from that link i thought that for private messages i should write
Code: Select all
User sender = sender = (User) ieo.getObject("user");
Code: Select all
User sender = sender = (User) ieo.getObject("sender");