<commit_before>#include <YSI\y_hooks>
static
	irc_Active,
	irc_Serv[32],
	irc_Port,
	irc_ChatChan[32],
	irc_ChatPass[32],
	irc_StaffChan[32],
	irc_StaffPass[32],
	irc_BotNick[32],
	irc_BotName[32],
	irc_BotUser[32],
	irc_BotMail[64],
	irc_BotPass[32];


static
	irc_Bot,
	irc_Group;


hook OnScriptInit()
{
	print("\n[OnScriptInit] Initialising 'IRC'...");

	GetSettingInt		("irc/use-irc",		0,					irc_Active);
	GetSettingString	("irc/serv",		"irc.tl",			irc_Serv);
	GetSettingInt		("irc/port",		6667,				irc_Port);
	GetSettingString	("irc/chat-chan",	"#MyChatChannel",	irc_ChatChan);
	GetSettingString	("irc/chat-pass",	"changeme",			irc_ChatPass);
	GetSettingString	("irc/staff-chan",	"#MyStaffChannel",	irc_StaffChan);
	GetSettingString	("irc/staff-pass",	"changeme",			irc_StaffPass);
	GetSettingString	("irc/bot-name",	"SS-Bot",			irc_BotName);
	GetSettingString	("irc/bot-nick",	"SS-Bot",			irc_BotNick);
	GetSettingString	("irc/bot-pass",	"changeme",			irc_BotPass);
	GetSettingString	("irc/bot-mail",	"<EMAIL>",			irc_BotMail);
	GetSettingString	("irc/bot-user",	"SS-Bot",			irc_BotUser);

	if(!irc_Active)
		return 1;

	if(!strcmp(irc_BotPass, "changeme"))
	{
		print("ERROR: Please set the IRC bot password in settings.json");
		for(;;){}
	}

	if(!strcmp(irc_BotMail, "<EMAIL>"))
	{
		print("ERROR: Please set the IRC bot email in settings.json");
		for(;;){}
	}

	irc_Bot = IRC_Connect(irc_Serv, irc_Port, irc_BotNick, irc_BotName, irc_BotUser);
	IRC_SetIntData(irc_Bot, E_IRC_CONNECT_DELAY, 20);

	irc_Group = IRC_CreateGroup();

	return 1;
}

hook OnGameModeExit()
{
	if(!irc_Active)
		return 1;

	IRC_Quit(irc_Bot, "Gamemode Closing/Restarting");

	IRC_DestroyGroup(irc_Group);

	return 1;
}


hook OnPlayerConnect(playerid)
{
	if(!irc_Active)
		return 1;

	// If the server is booting up after a restart, don't send connects.
	if(gServerInitialising)
		return 1;

	new
		joinMsg[128],
		name[MAX_PLAYER_NAME + 1];

	GetPlayerName(playerid, name, sizeof(name));
	strins(name, ".", 1);

	format(joinMsg, sizeof(joinMsg), " >>> [%d][%s] has joined the server.", playerid, name);
	IRC_GroupSay(irc_Group, irc_ChatChan, joinMsg);
	IRC_GroupSay(irc_Group, irc_StaffChan, joinMsg);

	return 1;
}

hook OnPlayerDisconnect(playerid, reason)
{
	if(!irc_Active)
		return 1;

	// If the server is restarting, don't send disconnects.
	if(gServerRestarting)
		return 1;

	new
		leaveMsg[128],
		name[MAX_PLAYER_NAME + 1],
		reasonMsg[8];

	switch(reason)
	{
		case 0: reasonMsg = "Timeout";
		case 1: reasonMsg = "Leaving";
		case 2: reasonMsg = "Kicked";
	}

	GetPlayerName(playerid, name, sizeof(name));
	strins(name, ".", 1);

	format(leaveMsg, sizeof(leaveMsg), " <<< [%d][%s] has left the server. (%s)", playerid, name, reasonMsg);
	IRC_GroupSay(irc_Group, irc_ChatChan, leaveMsg);
	IRC_GroupSay(irc_Group, irc_StaffChan, leaveMsg);

	return 1;
}

public OnPlayerSendChat(playerid, text[], Float:frequency)
{
	if(irc_Active)
		_IRC_HandleServerChat(playerid, text, frequency);

	#if defined irc_OnPlayerSendChat
		return irc_OnPlayerSendChat(playerid, text, frequency);
	#else
		return 0;
	#endif
}
#if defined _ALS_OnPlayerSendChat
	#undef OnPlayerSendChat
#else
	#define _ALS_OnPlayerSendChat
#endif
 
#define OnPlayerSendChat irc_OnPlayerSendChat
#if defined irc_OnPlayerSendChat
	forward irc_OnPlayerSendChat(playerid, text[], Float:frequency);
#endif

_IRC_HandleServerChat(playerid, text[], Float:frequency)<commit_msg>Removed staff IRC channel join/part messages<commit_after>#include <YSI\y_hooks>
static
	irc_Active,
	irc_Serv[32],
	irc_Port,
	irc_ChatChan[32],
	irc_ChatPass[32],
	irc_StaffChan[32],
	irc_StaffPass[32],
	irc_BotNick[32],
	irc_BotName[32],
	irc_BotUser[32],
	irc_BotMail[64],
	irc_BotPass[32];


static
	irc_Bot,
	irc_Group;


hook OnScriptInit()
{
	print("\n[OnScriptInit] Initialising 'IRC'...");

	GetSettingInt		("irc/use-irc",		0,					irc_Active);
	GetSettingString	("irc/serv",		"irc.tl",			irc_Serv);
	GetSettingInt		("irc/port",		6667,				irc_Port);
	GetSettingString	("irc/chat-chan",	"#MyChatChannel",	irc_ChatChan);
	GetSettingString	("irc/chat-pass",	"changeme",			irc_ChatPass);
	GetSettingString	("irc/staff-chan",	"#MyStaffChannel",	irc_StaffChan);
	GetSettingString	("irc/staff-pass",	"changeme",			irc_StaffPass);
	GetSettingString	("irc/bot-name",	"SS-Bot",			irc_BotName);
	GetSettingString	("irc/bot-nick",	"SS-Bot",			irc_BotNick);
	GetSettingString	("irc/bot-pass",	"changeme",			irc_BotPass);
	GetSettingString	("irc/bot-mail",	"<EMAIL>",			irc_BotMail);
	GetSettingString	("irc/bot-user",	"SS-Bot",			irc_BotUser);

	if(!irc_Active)
		return 1;

	if(!strcmp(irc_BotPass, "changeme"))
	{
		print("ERROR: Please set the IRC bot password in settings.json");
		for(;;){}
	}

	if(!strcmp(irc_BotMail, "<EMAIL>"))
	{
		print("ERROR: Please set the IRC bot email in settings.json");
		for(;;){}
	}

	irc_Bot = IRC_Connect(irc_Serv, irc_Port, irc_BotNick, irc_BotName, irc_BotUser);
	IRC_SetIntData(irc_Bot, E_IRC_CONNECT_DELAY, 20);

	irc_Group = IRC_CreateGroup();

	return 1;
}

hook OnGameModeExit()
{
	if(!irc_Active)
		return 1;

	IRC_Quit(irc_Bot, "Gamemode Closing/Restarting");

	IRC_DestroyGroup(irc_Group);

	return 1;
}


hook OnPlayerConnect(playerid)
{
	if(!irc_Active)
		return 1;

	// If the server is booting up after a restart, don't send connects.
	if(gServerInitialising)
		return 1;

	new
		joinMsg[128],
		name[MAX_PLAYER_NAME + 1];

	GetPlayerName(playerid, name, sizeof(name));
	strins(name, ".", 1);

	format(joinMsg, sizeof(joinMsg), " >>> [%d][%s] has joined the server.", playerid, name);
	IRC_GroupSay(irc_Group, irc_ChatChan, joinMsg);

	return 1;
}

hook OnPlayerDisconnect(playerid, reason)
{
	if(!irc_Active)
		return 1;

	// If the server is restarting, don't send disconnects.
	if(gServerRestarting)
		return 1;

	new
		leaveMsg[128],
		name[MAX_PLAYER_NAME + 1],
		reasonMsg[8];

	switch(reason)
	{
		case 0: reasonMsg = "Timeout";
		case 1: reasonMsg = "Leaving";
		case 2: reasonMsg = "Kicked";
	}

	GetPlayerName(playerid, name, sizeof(name));
	strins(name, ".", 1);

	format(leaveMsg, sizeof(leaveMsg), " <<< [%d][%s] has left the server. (%s)", playerid, name, reasonMsg);
	IRC_GroupSay(irc_Group, irc_ChatChan, leaveMsg);

	return 1;
}

public OnPlayerSendChat(playerid, text[], Float:frequency)
{
	if(irc_Active)
		_IRC_HandleServerChat(playerid, text, frequency);

	#if defined irc_OnPlayerSendChat
		return irc_OnPlayerSendChat(playerid, text, frequency);
	#else
		return 0;
	#endif
}
#if defined _ALS_OnPlayerSendChat
	#undef OnPlayerSendChat
#else
	#define _ALS_OnPlayerSendChat
#endif
 
#define OnPlayerSendChat irc_OnPlayerSendChat
#if defined irc_OnPlayerSendChat
	forward irc_OnPlayerSendChat(playerid, text[], Float:frequency);
#endif

_IRC_HandleServerChat(playerid, text[], Float:frequency)
{'fraction_non_alphanumeric': 0.14472909305064782, 'fraction_numerical': 0.015312131919905771, 'mean_word_length': 5.550626808100289, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3200410', 'n_tokens_mistral': 3026, 'n_tokens_neox': 2675, 'n_words': 536}