Code:
#include <amxmodx>
#include <amxmisc>
#include <regex>
// Preprocessor macros (Config)
#define KICK_NICK_REASON "Spam in nick!"
#define IN_GAME_WARNING_MSG "Advertising other servers or web sites is strictly prohibited!"
#define KICK_MSG_REASON "Spam message!"
#define MSG_BLOCK_INFO "Advertising on your behalf, please do not advertise other sites/servers"
public plugin_init()
{
register_plugin("Anti-Spam Lite", "1.0.4", "NullWarez")
register_clcmd("say","check_player_msg")
register_clcmd("say_team","check_player_msg")
}
// Check the nick when connecting
public client_connect(id)
{
if(is_user_admin(id))
return PLUGIN_CONTINUE
new g_name[32]
get_user_name(id, g_name,31)
if(is_invalid(g_name))
{
server_cmd("kick #%d Disallowed nickname!", get_user_userid(id))
return PLUGIN_CONTINUE
}
set_task(20.0, "showWarning", id)
return PLUGIN_CONTINUE
}
// Checks the message for spam
bool:is_invalid(const text[])
{
new error[168], num
new Regex:regex = regex_match (text, "\b(?:\d{1,3}(\,|\<|\>|\~|\«|\»|\=|\.|\s|\*|\')){3}\d{1,3}\b", num, error, charsmax(error))
if(regex >= REGEX_OK)
{
regex_free(regex)
return true
}
return false
}
// Displays a warning ban for spam
public showWarning(id)
{
if(is_user_connected(id))
client_print(id, print_chat, "Advertising other servers or web sites is strictly prohibited!")
}
// Check say or say_team message
public check_player_msg(id)
{
if(is_user_admin(id))
return PLUGIN_CONTINUE
new text[128]
read_args(text,127)
if(is_invalid(text))
{
client_print(id, print_chat, "Advertising other servers or web sites is strictly prohibited!")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
// Called when set name
public client_infochanged(id)
{
if(is_user_admin(id))
return PLUGIN_CONTINUE
if(!is_user_alive(id)) // loop fix
return PLUGIN_CONTINUE
new g_name[32]
get_user_name(id, g_name,31)
if(is_invalid(g_name))
{
server_cmd("kick #%d Disallowed nickname!", get_user_userid(id))
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
Code:
\d+(\.|\s|\+|_|\:|,)\d(\.|\s|\+|_|\:|,)\d(\.|\s|\+|_|\:|,)\d(\.|\s|\+|_|\:|,)\d+