Thread: Don't say IPs
View Single Post
Astro
Member
Join Date: Jul 2011
Old 02-15-2012 , 11:06   Re: Don't say IPs
Reply With Quote #72

PHP Code:
#define PATTERN "(?:(?:2\s*5\s*[0-5]|2\s*[0-4]\s*[0-9]|1\s*[0-9]\s*[0-9]|[1-9]?\s*[0-9])\s*\.\s*){3}(?:2\s*5\s*[0-5]|2\s*[0-4]\s*[0-9]|1\s*[0-9]\s*[0-9]|[1-9]?\s*[0-9])" 
will match 1 2 3 . 1 2 3 . 1 2 3 . 1 2 3, 123.123.123.123, 1 23. 12 3 . 1 2 3 .1 23 etc.

Eventually you could use my editted version. It checks say and say_team (the original plugin doesn't), blocks the message completely and prints informational message in green to spammer only.

PHP Code:
/*
Copyleft 2005
Plugin topic: http://www.amxmodx.org/forums/viewtopic.php?p=90172


Don't say IPs
=============
Messages like "hey join my server 213.34.231.23" are automatically blocked... and another message is printed instead. :-P
Or, you can choose to just ban violators by setting cvar ip_banviolators to 1 and ip_banminutes to how many minutes the violator should be banned. 0 is permanent, 5 is default.

/JGHG


VERSIONS
========
050204    0.1    First version


CREDITS
=======
Requested by lord_inuyasha88.
*/

#include <amxmodx>
#include <regex>

#define PLUGINNAME    "Don't say IPs"
#define VERSION        "0.1"
#define AUTHOR        "JGHG"
#define PATTERN                "(?:(?:2\s*5\s*[0-5]|2\s*[0-4]\s*[0-9]|1\s*[0-9]\s*[0-9]|[1-9]?\s*[0-9])\s*\.\s*){3}(?:2\s*5\s*[0-5]|2\s*[0-4]\s*[0-9]|1\s*[0-9]\s*[0-9]|[1-9]?\s*[0-9])"

//#define PRINTTOALL
#define MESSAGE "[DIP] Your message contained IP address and was blocked."

// Variables
new iResultRegex:hPatterniReturnValueszError[64], szAllArgs[1024],  iSayTextszMessage[256];

#if defined PRINTTOALL
new iCount 1iPlayers[32]
#endif

public plugin_modules() 

    
require_module("regex");
}

public 
hook_say(idlevelcid
{
    
read_args(szAllArgs1023);
    
    
iResult regex_match_c(szAllArgshPatterniReturnValue);
    
    switch (
iResult
    {
    case 
REGEX_MATCH_FAIL
        {
            
log_amx("REGEX_MATCH_FAIL! %s"szError);
            return 
PLUGIN_CONTINUE;
        }
    case 
REGEX_PATTERN_FAIL
        {
            
log_amx("REGEX_PATTERN_FAIL! %s"szError);
            return 
PLUGIN_CONTINUE;
        }
    case 
REGEX_NO_MATCH
        {
            return 
PLUGIN_CONTINUE;
        }
    default: 
        {
            
szMessage[0] = 0x04;
            
format(szMessage[1], 251MESSAGE);
            
szMessage[192] = '^0';
            
#if defined PRINTTOALL
            
get_players(iPlayersiCount"ch");
            
            for (new 
0iCounti++)
            {
                if (
is_user_connected(iPlayers[i]))
                {
                    
message_begin(MSG_ONE_UNRELIABLEiSayText_iPlayers[i]);
                    
write_byte(iPlayers[i]);
                    
write_string(szMessage);
                    
message_end();
                }
            }
#else
            
message_begin(MSG_ONEiSayText_id);
            
write_byte(id);
            
write_string(szMessage);
            
message_end();
#endif
            
            
return PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
plugin_init() 
{
    
register_plugin(PLUGINNAMEVERSIONAUTHOR);
    
    
register_clcmd("say""hook_say");
    
register_clcmd("say_team""hook_say");
    
    
register_dictionary("admincmd.txt");
    
    
iSayText get_user_msgid("SayText");
    
    
hPattern regex_compile(PATTERNiReturnValueszError63"i");
}

public 
plugin_end() {
    
regex_free(hPattern);   

EDIT:
Quote:
Originally Posted by Danidude
Hey can u edit ur pluin in which the message is shown to everyone?
PHP Code:
//Find and uncomment PRINTTOALL = remove // before
#define PRINTTOALL 

Last edited by Astro; 06-02-2012 at 07:54. Reason: Posted my version of the plugin.
Astro is offline