Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ----- IRC Script -----
- g_IRC <- null;
- // CHANGEME
- IRC_SERVER <- "irc.liberty-unleashed.co.uk";
- IRC_ECHO_CHANNEL <- "#extreme-addicts.echo";
- IRC_NICKNAME <- "Quack";
- const IRC_COL_WHITE = "\x000300";
- const IRC_COL_BLACK = "\x000301";
- const IRC_COL_DARKBLUE = "\x000302";
- const IRC_COL_DARKGREEN = "\x000303";
- const IRC_COL_RED = "\x000304";
- const IRC_COL_BROWN = "\x000305";
- const IRC_COL_PURPLE = "\x000306";
- const IRC_COL_ORANGE = "\x000307";
- const IRC_COL_YELLOW = "\x000308";
- const IRC_COL_GREEN = "\x000309";
- const IRC_COL_AQUA = "\x000310";
- const IRC_COL_CYAN = "\x000311";
- const IRC_COL_BLUE = "\x000312";
- const IRC_COL_PINK = "\x000313";
- const IRC_COL_DARKGREY = "\x000314";
- const IRC_COL_LIGHTGREY = "\x000315";
- const IRC_COL = "\x0003";
- const IRC_COL_BOLD = "\x0002";
- function EchoMessage( out )
- {
- Message( out );
- IRC_PrivMsg( g_IRC, IRC_ECHO_CHANNEL, out );
- }
- function IRC_onRaw( irc, host, data )
- {
- //print( host + " - " + data );
- }
- // Fired 10 seconds after disconnecting to reconnect
- function ReconnectIRC( irc )
- {
- print( "Attempting to reconnect to IRC..." );
- if ( IRC_Connect( irc ) == true )
- print( "Reconnected successfully" );
- else
- {
- print( "Unable to reconnect. Retrying in 10 seconds..." );
- NewTimer( "ReconnectIRC", 10000, 1, irc );
- }
- }
- function IRC_onDisconnect( irc )
- {
- print( "IRC bot has disconnected from the server. Reconnecting..." );
- if ( IRC_Connect( irc ) == true )
- print( "Reconnected successfully" );
- else
- {
- print( "Unable to reconnect. Retrying in 10 seconds..." );
- NewTimer( "ReconnectIRC", 10000, 1, irc );
- }
- }
- function IRC_onNumeric( irc, numeric, host, data )
- {
- if ( numeric == 001 )
- {
- // Numeric 1 is the RPL_WELCOME message which means we have connected
- // Join our channel
- IRC_Join( irc, IRC_ECHO_CHANNEL, "" );
- }
- }
- function IRC_onJoin( irc, host, data )
- {
- // Called when somebody joins the channel
- local nick = split( host, "!:" )[0];
- local chan = split( data, ":" )[0];
- if ( nick == IRC_GetNick( irc ) )
- {
- // We joined a channel
- print( "Joined channel " + chan + " on " + IRC_GetNetworkName( irc ) );
- }
- }
- function IRC_onPrivMsg( irc, host, channel, message )
- {
- local nick = split( host, "!:" )[0];
- local cmd = GetTok( message, " ", 1 );
- if ( cmd == "!playercount" )
- {
- // Return how many players are on the server
- IRC_PrivMsg( irc, IRC_ECHO_CHANNEL, "There are currently " + GetPlayers() + "/" + GetMaxPlayers() + " players on the server." );
- }
- else if ( cmd == "!kick" )
- {
- local modes = IRC_GetUserModes( irc, channel, nick );
- if ( modes != "" )
- {
- if ( IsIn( modes, "o" ) )
- {
- // Person has operator on the channel
- local numArgs = NumTok( message, " " );
- if ( numArgs > 1 )
- {
- local user = GetTok( message, " ", 2 );
- local reason = "No Reason";
- if ( numArgs >= 3 )
- reason = GetTok( message, " ", 3, numArgs );
- local plr = null;
- if ( IsNum( user ) ) plr = FindPlayer( user.tointeger() );
- else plr = FindPlayer( user );
- if ( plr )
- {
- EchoMessage( "IRC Admin " + nick + " has kicked " + plr + " [" + reason + "]" );
- KickPlayer( plr );
- }
- else
- IRC_PrivMsg( irc, IRC_ECHO_CHANNEL, "Player not found." );
- }
- }
- }
- }
- else if ( cmd == "!ban" )
- {
- local modes = IRC_GetUserModes( irc, channel, nick );
- if ( modes != "" )
- {
- if ( IsIn( modes, "a" ) )
- {
- // Person has operator on the channel
- local numArgs = NumTok( message, " " );
- if ( numArgs > 1 )
- {
- local user = GetTok( message, " ", 2 );
- local reason = "No Reason";
- if ( numArgs >= 3 )
- reason = GetTok( message, " ", 3, numArgs );
- local plr = null;
- if ( IsNum( user ) ) plr = FindPlayer( user.tointeger() );
- else plr = FindPlayer( user );
- if ( plr )
- {
- EchoMessage( "IRC Admin " + nick + " has kicked " + plr + " [" + reason + "]" );
- BanPlayer( plr );
- }
- else
- IRC_PrivMsg( irc, IRC_ECHO_CHANNEL, "Player not found." );
- }
- }
- }
- }
- else
- {
- // If a command hasnt been issued, send the message
- if ( channel == IRC_ECHO_CHANNEL )
- {
- if ( cmd[0] != '.' )
- Message( "(IRC) " + nick + ": " + message );
- }
- }
- //print( "(" + channel + ") " + nick + ": " + message );
- }
- function onPlayerJoin( plr )
- {
- IRC_PrivMsg( g_IRC, IRC_ECHO_CHANNEL, IRC_COL_LIGHTGREY + "[" + plr.ID + "] " + IRC_COL_BROWN + plr.Name + " has joined the server." );
- }
- function onPlayerPart( plr, reasonid )
- {
- local reason = "Unknown";
- switch ( reasonid )
- {
- case PARTREASON_DISCONNECTED:
- reason = "Disconnected";
- break;
- case PARTREASON_TIMEOUT:
- reason = "Timeout";
- break;
- case PARTREASON_KICKED:
- reason = "Kicked";
- break;
- case PARTREASON_BANNED:
- reason = "Banned";
- break;
- }
- IRC_PrivMsg( g_IRC, IRC_ECHO_CHANNEL, IRC_COL_LIGHTGREY + "[" + plr.ID + "] " + IRC_COL_BROWN + plr.Name + " has left the server. " + IRC_COL_RED + "[" + reason + "]" );
- }
- function onPlayerChat( plr, text )
- {
- IRC_PrivMsg( g_IRC, IRC_ECHO_CHANNEL, IRC_COL_LIGHTGREY + "[" + plr.ID + "] " + IRC_COL_AQUA + plr.Name + IRC_COL + ": " + text );
- }
- function onConsoleInput( cmd, text )
- {
- if ( cmd == "irc_join" )
- {
- IRC_Join( g_IRC, text, "" );
- }
- else if ( cmd == "irc_echo" )
- {
- IRC_PrivMsg( g_IRC, IRC_ECHO_CHANNEL, "Switching echo to " + text );
- IRC_Part( g_IRC, IRC_ECHO_CHANNEL, "Moving echo channel" );
- IRC_Join( g_IRC, text, "" );
- IRC_PrivMsg( g_IRC, text, "Echo channel has been moved to here from " + IRC_ECHO_CHANNEL );
- IRC_ECHO_CHANNEL <- text;
- }
- }
Add Comment
Please, Sign In to add comment