Blockland Forums > Suggestions & Requests

serverCmdMessageSent source

Pages: << < (2/4) > >>

Port:

Uh.. feels like there's a ton missing in that.

-Jetz-:


--- Quote from: Port on January 27, 2014, 06:43:15 AM ---Uh.. feels like there's a ton missing in that.

--- End quote ---
There is. That isn't how spam detection is done for starters, nor-flood detection, e-tard is missing, never strips out control characters, and link parsing is absent. Again, if you want a good replica of it, take Greek's from Slayer.

Port:


--- Quote from: -Jetz- on January 27, 2014, 08:48:03 AM ---There is.

--- End quote ---

serverCmdStopTalking and a few other things are also missing.


--- Quote from: -Jetz- on January 27, 2014, 08:48:03 AM ---nor-flood detection

--- End quote ---

     if(spamAlert(%client))
         return; //flood?

Albeit checks for successive messages are missing.


--- Quote from: -Jetz- on January 27, 2014, 08:48:03 AM ---never strips out control characters

--- End quote ---

     %text=stripMlControlChars(%text);


There's a ton of really weird stuff in here.

     %text=lTrim(trim(%text));

Actually, it's not even gonna work.

> %entiremessage = '\c7%1\c3%2\c7%3\c6: %4'@"
>                                          ^ syntax error

Greek2me:

This is basically what I use in Slayer.

Keep in mind that only one mod can use this at a time, so users might be annoyed if your mod breaks other mods.


--- Code: ---function serverCmdMessageSent(%client, %msg)
{
serverCmdStopTalking(%client);

%msg = stripMLControlChars(trim(%msg));

%length = strLen(%msg);
if(!%length)
return;

%time = getSimTime();

if(!%client.isSpamming)
{
//did they repeat the same message recently?
if(%msg $= %client.lastMsg && %time - %client.lastMsgTime < $SPAM_PROTECTION_PERIOD)
{
messageClient(%client,'',"\c5Do not repeat yourself.");
if(!%client.isAdmin)
{

%client.isSpamming = true;
%client.spamProtectStart = %time;
%client.schedule($SPAM_PENALTY_PERIOD,spamReset);
}
}

//are they sending messages too quickly?
if(!%client.isAdmin)
{
if(%client.spamMessageCount >= $SPAM_MESSAGE_THRESHOLD)
{
%client.isSpamming = true;
%client.spamProtectStart = %time;
%client.schedule($SPAM_PENALTY_PERIOD,spamReset);
}
else
{
%client.spamMessageCount ++;
%client.schedule($SPAM_PROTECTION_PERIOD,spamMessageTimeout);
}
}
}

//tell them they're spamming and block the message
if(%client.isSpamming)
{
spamAlert(%client);
return;
}

//eTard Filter,  which I hate,  but have to include
if($Pref::Server::eTardFilter)
{
%list = strReplace($Pref::Server::eTardList,",","\t");

for(%i = 0; %i < getFieldCount(%list); %i ++)
{
%wrd = trim(getField(%list,%i));
if(%wrd $= "")
continue;
if(striPos(" " @ %msg @ " "," " @ %wrd @ " ") >= 0)
{
messageClient(%client,'',"\c5This is a civilized game. Please use full words.");
return;
}
}
}

//URLs
for(%i = 0; %i < getWordCount(%msg); %i ++)
{
%word = getWord(%msg, %i);
%pos = strPos(%word, "://") + 3;
%pro = getSubStr(%word, 0, %pos);
%url = getSubStr(%word, %pos, strLen(%word));

if((%pro $= "http://" || %pro $= "https://") && strPos(%url, ":") == -1)
{
%word = "<sPush><a:" @ %url @ ">" @ %url @ "</a><sPop>";
%msg = setWord(%msg, %i, %word);
}
}

//MESSAGE FORMAT
%all  = '\c7%1\c3%2\c7%3\c6: %4';
%name = %client.getPlayerName();
%pre  = %client.clanPrefix;
%suf  = %client.clanSuffix;

commandToAll('chatMessage', %client, '', '', %all, %pre, %name, %suf, %msg);

echo(%client.getSimpleName() @ ":" SPC %msg);

%client.lastMsg = %msg;
%client.lastMsgTime = %time;

if(isObject(%client.player))
{
%client.player.playThread(3, "talk");
%client.player.schedule(%length * 50, playThread, 3, "root");
}
}
--- End code ---


-Jetz-:


--- Quote from: Port on January 27, 2014, 08:57:39 AM ---      if(spamAlert(%client))
         return; //flood?

--- End quote ---
I'm pretty sure that doesn't actually do anything to prevent spam.


--- Quote from: Port on January 27, 2014, 08:57:39 AM ---serverCmdStopTalking and a few other things are also missing.

--- End quote ---
Was just going over the big things.


--- Quote from: Port on January 27, 2014, 08:57:39 AM ---      %text=stripMlControlChars(%text);

--- End quote ---
Didn't see that.

Pages: << < (2/4) > >>

Go to full version