PDA

View Full Version : Using filters



dwlee
07-11-2008, 10:27 AM
Hi,

I realize that I wrote my own chat manager plugin which manages the chat messages that goes from one player to another player. And I need to scan through each message for any foul words. I notice in the web administrator tool, there is a filter language that is being used. I assume this applies to the UserPublicMessageContext? But I would like to make use of the words that we define in the root list and the full words list into my chat manager plugin as well. Is there any way where I can pull out those words and use it in my chat manager plugin?

edited by Teresa to give a more specific subject line

tcarr
07-11-2008, 04:25 PM
Is there a reason that you don't want to just have the automatic filters work the way that they do for public messages? See the wiki's article on Filters (http://www.es-wiki.com/index.php?title=Filters).

To use the language filters from a plugin, you should be able to use getApi().applyLanguageFilterToString (http://www.electro-server.com/documentation/docs/es4/server/extension/com/electrotank/electroserver4/extensions/api/ElectroServerApi.html#applyLanguageFilterToString( java.lang.String,%20java.lang.String)).

I don't know of any way to get the list of the filter words though.

dwlee
08-12-2008, 11:57 AM
Hey Teresa,

I tried using the getApi().applyLanguageFilterToString() method and everytime I created a language filter through the web admin, it says it cannot find my language filter name. What could be the cause of it?

The reason why I need to do it this way because we created a chat program that can be used to chat with many members and we want to record the messages into the database. That's why we cannot just use the AS api to send private message to another user, it has to go through the server so that it can save the message. So that means we created a service for doing this feature. You can think of it being similar to http://www.es-wiki.com/index.php?title=Advanced_Chat_Tutorial

But we also want to use ES filter features where if it detects a bad word then it'll ban the user accordingly to what is configured on the web admin. Is it possible? Can it be done?

Thanks!

dwlee
08-13-2008, 12:58 AM
Lots of viewer, any takers on suggesting how it could be done?

tcarr
08-13-2008, 01:06 AM
I have no experience with this myself, sorry. The project I worked on where we needed to use plugin messages for chat and have that chat filtered had such complicated chat filtering rules that we couldn't use the built in ones.

dwlee
08-13-2008, 01:21 AM
Mine is not complicated filter.

I just create lang filter through web admin.
Put in the words I want to scan for
Restart ES
In my plugin for the handling chat message
When I receive a request from the client, I open out hte EsObject and search for my MESSAGE
Pass through the message to be scanned using getApi().applyLanguageFilter(<filter name I've created, MESSAGE)

But the result says that it could not find the LanguageFilterName. I remember reading somewhere that we have to create a language filter per room/zone?? How do I do this for dynamic room/zone creation?

tcarr
08-13-2008, 01:25 AM
Is the room created by the client or by a plugin?

dwlee
08-13-2008, 01:27 AM
client...

tcarr
08-13-2008, 01:38 AM
In your CreateRoomRequest, before you send it, try doing:

crr.setIsUsingLanguageFilter();

If you want to use a filter other than the default one, you also need to use setLanguageFilterName and specify the name of the language filter.

dwlee
08-13-2008, 01:50 AM
is this all client code??

we cant do this in client code because we want the server to deal with the language issue because we create a chat program and the message will just get sent to the server and the server needs to filter out the language based on the list from the language filter created through the web admin

tcarr
08-13-2008, 01:55 AM
But you just said that the room was being created by the client, not by a plugin. I'm confused. Whichever one creates the room has to add the language filter and enable it. What I gave above is for when the client creates the room using CreateRoomRequest.

When a plugin creates a room, you can use getApi().createRoom(int zoneId,
RoomConfiguration roomConfig,
UserConfig[] userConfigs)

where the roomConfig has already had isUsingLanguageFilter() and setLanguageFilterName etc. done to it.

dwlee
08-13-2008, 02:16 AM
i see....

well...this is how we did it...all room creation are done by the client...the client will use a plugin called ChatPlugin which deals with all the chat services done in the request().

So in the client code,
1) Create the room
2) Set language filter (need to be added)
3) Encapsulate the message into an EsObject (eg. esObject.setString("message", "what f-up");
4) calls one of the ChatPlugin

On the server side
1) request() will determine what action it is (we usually put some code into the EsObject to determine what service needs to be handled eg. esObject.setInteger("Action", "sendingChatMessage");
2) the server then needs to apply filter language

Can I do this. Even though the rooms are created on the client side. My chat plugin is not related to any rooms, but can I set the language filter to this chat plugin, then make a call to getApi().applyLanguageFilter()?? I dont think BasePlugin Api support such method and it looks like we are restricted to whoever creates the room will be able to set the lang filter, right?

sankar.balaji
09-28-2008, 02:48 PM
Hi Teresa,

Long time, no see.. :) Well. I am also stuck in the same problem.. Following is the code i am using for creating rooms from plugins. And you can see i am adding them to use their default language and flooding filters.. But its not working.. Users are freely using the foul languages



private void createRoomInZone(String zoneName, String roomName, int capacity, ExtensionComponentConfiguration roomPlugin, RoomVariable roomVar)
{

try
{
RoomConfiguration roomConfig = new RoomConfiguration();
roomConfig.setName(roomName);
roomConfig.setCapacity(capacity);
roomConfig.setPersistent(true);
roomConfig.addPlugin(roomPlugin);
roomConfig.setUsingFloodingFilter(true);
roomConfig.setUsingLanguageFilter(true);
roomConfig.setNonOperatorUpdateAllowed(true);
roomConfig.setNonOperatorVariableUpdateAllowed(tru e);
if ( roomVar != null )
roomConfig.addVariable(roomVar);

UserConfig[] userConfigs = new UserConfig[0];

RoomResponse response = getApi().createRoomInNamedZone(zoneName, false, roomConfig, userConfigs);
if (response.getStatus() == Status.Success)
{
//System.out.println(" Room Successfully created. --> "+response.getZoneId()+" : "+response.getRoomId());
}
else
{
for (ErrorType error : response.getErrors())
{
System.out.println("Error while creating room "+response.getRoomId()+" Error: "+error.toString());
}
}
}
catch(Exception e)
{
logger.error("AdminPlugin: createRoomInZone: Caught exception while creating room "+roomName+"in zone "+zoneName+" error "+printException(e));
}
}



Point to be noted here is, any room created from the client and the filters attached from the client works fine.. Only the server created rooms are having this problem.. But I have a requirement to create certain rooms from the server. Please help.

Thanks
Sankar