ChatFilter: Push to git, unfinished.
This commit is contained in:
parent
c8b3433700
commit
da526d925a
11
ChatFilter/configs/chatfilters.cfg
Normal file
11
ChatFilter/configs/chatfilters.cfg
Normal file
@ -0,0 +1,11 @@
|
||||
"chatfilters"
|
||||
{
|
||||
"#lennies"
|
||||
{
|
||||
"( ͡° ͜ʖ ͡°)" {}
|
||||
}
|
||||
"#entWatch"
|
||||
{
|
||||
"[entWatch]" {}
|
||||
}
|
||||
}
|
129
ChatFilter/scripting/ChatFilter.sp
Normal file
129
ChatFilter/scripting/ChatFilter.sp
Normal file
@ -0,0 +1,129 @@
|
||||
#pragma newdecls required
|
||||
|
||||
#include <sourcemod>
|
||||
#include <regex>
|
||||
#include <ccc>
|
||||
|
||||
ArrayList g_aClientFilters[MAXPLAYERS+1];
|
||||
ArrayList g_aGroupFilters[MAXPLAYERS+1];
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "ChatFilter",
|
||||
author = "zaCade",
|
||||
description = "Allows users to filter their chat messages",
|
||||
version = "1.0.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
RegConsoleCmd("sm_cf", Command_ChatFilter);
|
||||
RegConsoleCmd("sm_cfg", Command_ChatFilterGroup);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int client = 1; client <= MAXPLAYERS; client++)
|
||||
{
|
||||
g_aClientFilters[client] = new ArrayList(512);
|
||||
g_aGroupFilters[client] = new ArrayList(512);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientConnected(int client)
|
||||
{
|
||||
g_aClientFilters[client].Clear();
|
||||
g_aGroupFilters[client].Clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action Command_ChatFilter(int client, int args)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// g_aClientFilters[client].PushString(filter);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action Command_ChatFilterGroup(int client, int args)
|
||||
{
|
||||
|
||||
|
||||
|
||||
// ArrayList filters = new ArrayList(128);
|
||||
|
||||
|
||||
|
||||
// filters.PushString(filter);
|
||||
|
||||
|
||||
|
||||
// g_aGroupFilters[client].Push(filters);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action CCC_OnChatMessage(int client, int author, const char[] message)
|
||||
{
|
||||
bool bBlockMessage = false;
|
||||
|
||||
// Check the clients own filter list.
|
||||
if (!bBlockMessage && g_aClientFilters[client].Length)
|
||||
{
|
||||
for (int filterID; filterID < g_aClientFilters[client].Length; filterID++)
|
||||
{
|
||||
char filter[128];
|
||||
g_aClientFilters[client].GetString(filterID, filter, sizeof(filter));
|
||||
|
||||
if (StrContains(message, filter, false))
|
||||
{
|
||||
bBlockMessage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check the clients group filter lists.
|
||||
if (!bBlockMessage && g_aGroupFilters[client].Length)
|
||||
{
|
||||
for (int groupID; groupID < g_aGroupFilters[client].Length; groupID++)
|
||||
{
|
||||
ArrayList filters = g_aGroupFilters[client].Get(groupID);
|
||||
|
||||
if (filters.Length)
|
||||
{
|
||||
for (int filterID; filterID < filters.Length; filterID++)
|
||||
{
|
||||
char filter[128];
|
||||
filters.GetString(filterID, filter, sizeof(filter));
|
||||
|
||||
if (StrContains(message, filter, false))
|
||||
{
|
||||
bBlockMessage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (bBlockMessage) ? Plugin_Handled : Plugin_Continue;
|
||||
}
|
191
ChatFilter/scripting/include/ccc.inc
Normal file
191
ChatFilter/scripting/include/ccc.inc
Normal file
@ -0,0 +1,191 @@
|
||||
/**
|
||||
* This is the include file for Custom Chat Colors
|
||||
* https://forums.alliedmods.net/showthread.php?t=186695
|
||||
* To check that Custom Chat Colors is installed and running, verify that the "ccc" library exists
|
||||
*/
|
||||
|
||||
#if defined _ccc_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _ccc_included
|
||||
|
||||
enum CCC_ColorType {
|
||||
CCC_TagColor,
|
||||
CCC_NameColor,
|
||||
CCC_ChatColor
|
||||
};
|
||||
|
||||
#define COLOR_NULL -1
|
||||
#define COLOR_NONE -2
|
||||
#define COLOR_CGREEN -3 //0x40FF40
|
||||
#define COLOR_OLIVE -4 //0x99FF99
|
||||
#define COLOR_TEAM -5
|
||||
|
||||
/**
|
||||
* Gets a client's color as a hexadecimal integer.
|
||||
*
|
||||
* @param client Client index
|
||||
* @param type Color type to retreive
|
||||
* @param alpha Pass a boolean variable by reference here and it will be true if the color has alpha specified or false if it doesn't (or is a stock color)
|
||||
* @return Color as a hexadecimal integer (use %X in formatting to get a hexadecimal string)
|
||||
*
|
||||
* On error/errors: Invalid client index or client is not in game
|
||||
*/
|
||||
native int CCC_GetColor(int client, CCC_ColorType type, bool &alpha = false);
|
||||
|
||||
/**
|
||||
* Sets a client's color as a hexadecimal integer.
|
||||
*
|
||||
* @param client Client index
|
||||
* @param type Color type to set
|
||||
* @param color Integer representation of the color (use StringToInt(input, 16) to convert a hexadecimal string) or one of the color defines
|
||||
* @param alpha Are you specifying a color with alpha?
|
||||
* @return True if the color is updated successfully, false otherwise
|
||||
*
|
||||
* On error/errors: Invalid client index or client is not in game
|
||||
*/
|
||||
native int CCC_SetColor(int client, CCC_ColorType type, int color, bool alpha);
|
||||
|
||||
/**
|
||||
* Gets a client's tag
|
||||
*
|
||||
* @param client Client index
|
||||
* @param buffer Buffer to store the tag in
|
||||
* @param maxlen Maximum buffer length
|
||||
* @noreturn
|
||||
*
|
||||
* On error/errors: Invalid client index or client is not in game
|
||||
*/
|
||||
native int CCC_GetTag(int client, char[] buffer, int maxlen);
|
||||
|
||||
/**
|
||||
* Sets a client's tag
|
||||
*
|
||||
* @param client Client index
|
||||
* @param tag String containing the new tag
|
||||
* @noreturn
|
||||
*
|
||||
* On error/errors: Invalid client index or client is not in game
|
||||
*/
|
||||
native void CCC_SetTag(int client, const char[] tag);
|
||||
|
||||
/**
|
||||
* Resets a client's color to the value in the config file.
|
||||
*
|
||||
* @param client Client index
|
||||
* @param type Color type to restore
|
||||
* @noreturn
|
||||
*
|
||||
* On error/errors: Invalid client index or client is not in game
|
||||
*/
|
||||
native int CCC_ResetColor(int client, CCC_ColorType type);
|
||||
|
||||
/**
|
||||
* Resets a client's tag to the value in the config file.
|
||||
*
|
||||
* @param client Client index
|
||||
* @noreturn
|
||||
*
|
||||
* On error/errors: Invalid client index or client is not in game
|
||||
*/
|
||||
native int CCC_ResetTag(int client);
|
||||
|
||||
/**
|
||||
* Called when a cilent's name is about to be colored
|
||||
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
|
||||
*
|
||||
* @param client Client index
|
||||
* @return Plugin_Handled to prevent coloring, Plugin_Continue to allow coloring
|
||||
*/
|
||||
//#pragma deprecated Use CCC_OnColor instead
|
||||
//forward Action:CCC_OnNameColor(client);
|
||||
|
||||
/**
|
||||
* Called when a client's chat is about to be colored
|
||||
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
|
||||
*
|
||||
* @param client Client index
|
||||
* @return Plugin_Handled to prevent coloring, Plugin_Continue to allow coloring
|
||||
*/
|
||||
//#pragma deprecated Use CCC_OnColor instead
|
||||
//forward Action:CCC_OnChatColor(client);
|
||||
|
||||
/**
|
||||
* Called when a client's name is about to be tagged
|
||||
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
|
||||
*
|
||||
* @param client Client index
|
||||
* @return Plugin_Handled to prevent tagging, Plugin_Continue to allow tagging
|
||||
*/
|
||||
//#pragma deprecated Use CCC_OnColor instead
|
||||
//forward Action:CCC_OnTagApplied(client);
|
||||
|
||||
/**
|
||||
* Called when a client's name is about to be tagged
|
||||
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
|
||||
*
|
||||
* @param client Client index
|
||||
* @param message Chat message that will be printed
|
||||
* @param type What type of color will be applied. If this is CCC_TagColor, it controls whether the tag will be applied at all, not whether the tag will be colored.
|
||||
* @return Plugin_Handled to prevent coloring, Plugin_Continue to allow coloring
|
||||
*/
|
||||
//forward Action:CCC_OnColor(client, const String:message[], CCC_ColorType:type);
|
||||
|
||||
/**
|
||||
* Called when a message has been fully colored and will be sent, unless further plugins modify it through Simple Chat Processor
|
||||
*
|
||||
* @param client Recieving client index
|
||||
* @param author Author client index
|
||||
* @param message Message
|
||||
* @return Plugin_Handled to block message, Plugin_Continue to allow message
|
||||
*/
|
||||
forward Action CCC_OnChatMessage(int client, int author, const char[] message);
|
||||
|
||||
/**
|
||||
* Called when a client's colors and tag are about to be loaded from the config file
|
||||
* At this point, the client has NO COLORS
|
||||
*
|
||||
* @param client Client index
|
||||
* @return Plugin_Handled or Plugin_Stop to prevent loading, Plugin_Continue or Plugin_Changed to allow
|
||||
*/
|
||||
forward Action CCC_OnUserConfigPreLoaded(int client);
|
||||
|
||||
/**
|
||||
* Called when a client's colors and tag have been loaded from the config file
|
||||
*
|
||||
* @param client Client index
|
||||
* @noreturn
|
||||
*/
|
||||
forward void CCC_OnUserConfigLoaded(int client);
|
||||
|
||||
/**
|
||||
* Called when the configuration file is reloaded with the sm_reloadccc command
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
forward void CCC_OnConfigReloaded();
|
||||
|
||||
native int CCC_UpdateIgnoredArray(bool IgnoredArray[(MAXPLAYERS + 1) * (MAXPLAYERS + 1)]);
|
||||
|
||||
public SharedPlugin __pl_ccc =
|
||||
{
|
||||
name = "ccc",
|
||||
file = "custom-chatcolors.smx",
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1
|
||||
#else
|
||||
required = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public __pl_ccc_SetNTVOptional() {
|
||||
MarkNativeAsOptional("CCC_GetColor");
|
||||
MarkNativeAsOptional("CCC_SetColor");
|
||||
MarkNativeAsOptional("CCC_GetTag");
|
||||
MarkNativeAsOptional("CCC_ResetTag");
|
||||
MarkNativeAsOptional("CCC_ResetColor");
|
||||
MarkNativeAsOptional("CCC_ResetTag");
|
||||
MarkNativeAsOptional("CCC_UpdateIgnoredArray");
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user