Author Topic: Chat filters  (Read 1833 times)

Alright, so I have been working on a project were when you say a word, it replaces that word with another character.

For example, the swear filter that is built in. If I said a "forbidden" word, it would be blocked with "*"s.

Heres a Small example on how it would "Catch" the word, but I need it to delete the entire message so it would be like the user never said it.
Code: [Select]
package SwearFilter
{
function serverCmdmessagesent(%client, %text)
{
if(strstr(%text, "Theword") >= 0)
messageClient(%client, '', "\c6Do not say that.");

parent::servercmdMessagesent(%client, %text);
}
};
activatePackage(Swearfilter);

Im sure this is possible. Can anyone help?
« Last Edit: October 13, 2010, 09:40:09 AM by computermix »

Calling the parent would send the message anyway

else
    parent::

Calling the parent would send the message anyway

else
    parent::

Im not completely into this "parent" stuff, can you give an example?

Code: [Select]
package SwearFilter
{
function serverCmdmessagesent(%client, %text)
{
if(strstr(%text, "Theword") >= 0)
messageClient(%client, '', "\c6Do not say that.");

else
    parent::servercmdMessagesent(%client, %text);
}
};
activatePackage(Swearfilter);

Code: [Select]
package SwearFilter
{
function serverCmdmessagesent(%client, %text)
{
if(strstr(%text, "Theword") >= 0)
messageClient(%client, '', "\c6Do not say that.");

else
    parent::servercmdMessagesent(%client, %text);
}
};
activatePackage(Swearfilter);
Dam your fast. Let me see...

Oh my, is there a way to make it case-sensitive? Because the built-in one is...
« Last Edit: October 12, 2010, 08:03:32 PM by computermix »

Oh my, is there a way to make it case-sensitive? Because the built-in one is...
I didn't realize the default checking method was case-sensitive.
Convert both strings to lower case and then check for a non-case-sensitive check.

Also, the whole word filtering thing is a bad idea.

I didn't realize the default checking method was case-sensitive.
Convert both strings to lower case and then check for a non-case-sensitive check.

Also, the whole word filtering thing is a bad idea.
Can you give an example? As in, I am new to scripting and "Strings"are a completely different case.(arnt they those words with "%" in front of them?) Oh yea, for the mark, I never said I was gonna make a word-blocker deal. Oh, and why?

%var = local variable. This function only.
$var = global variable. It stays until the console that defined it (yours, a server's, Badspot's secret hacking console, whatever) closes.

Both can be strings or not strings.

%var = local variable. This function only.
$var = global variable. It stays until the console that defined it (yours, a server's, Badspot's secret hacking console, whatever) closes.

Both can be strings or not strings.
I see. But what strings are capitalized? (In the code) and by when I talk Case sensitive... I mean, if the person says ThEwOrd it would catch it, because when You say "ThEwOrD", it down't catch it.
« Last Edit: October 12, 2010, 10:56:39 PM by computermix »

If you want it to be case-sensitive, use
Code: [Select]
if(strPos(%msg,"theWoRD") >= 0)If you want it to be case-insensitive, use
Code: [Select]
if(striPos(%msg,"theword") >= 0)


also, nonrelated topic title much? (Chat effects).



closes.
or does
Code: [Select]
deleteVariables("$PATTERN");
« Last Edit: October 13, 2010, 07:14:17 AM by Bauklotz »

If you want it to be case-sensitive, use
Code: [Select]
if(strPos(%msg,"theWoRD") >= 0)If you want it to be case-insensitive, use
Code: [Select]
if(striPos(%msg,"theword") >= 0)


also, nonrelated topic title much? (Chat effects).


or does
Code: [Select]
deleteVariables("$PATTERN");
I don't exactly want to write the words a million times, for example, If I made a swear filter...

Code: [Select]
package SwearFilter
{
function serverCmdmessagesent(%client, %text)
{
if(strstr(%text, "ass") >= 0) //"Section 1: Asses"
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "Ass") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "ASs") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "ASS") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "AsS") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "aSs") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "asS") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "aSS") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "A$s") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "As$") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "A$$") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "A$s") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "A$S") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "AS$") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "a$s") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "as$") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "a$$") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "A$s") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "a$s") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "a$S") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "a$s") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "@$$") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "@$s") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "@$S") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "@S$") >=0)
messageClient(%client, '', "\c6Do not say that.");

else if(strstr(%text, "@s$") >=0)
messageClient(%client, '', "\c6Do not say that.");//This burns my fingers.

else
    parent::servercmdMessagesent(%client, %text);
}
};
activatePackage(Swearfilter);

Then I have to do the other words, too. That would take forever!

Then use case-isensitivity, or use variables and a file reader that reads a file for words.

Then use case-isensitivity, or use variables and a file reader that reads a file for words.
It Semi-worked, as in I tried
Code: [Select]
"if(strpos(%text, "ass") >=0)"
and "ass" was blocked, but then I tried "ASS" and it failed. I think I have an idea.

It Semi-worked, as in I tried
Code: [Select]
"if(strpos(%text, "ass") >=0)"
and "ass" was blocked, but then I tried "ASS" and it failed. I think I have an idea.

You need to use striPos, not strPos.