Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ICOL_WHITE = "\x000300";
- const ICOL_BLACK = "\x000301";
- const ICOL_BLUE = "\x000302";
- const ICOL_GREEN = "\x000303";
- const ICOL_RED = "\x000304";
- const ICOL_BROWN = "\x000305";
- const ICOL_PURPLE = "\x000306";
- const ICOL_ORANGE = "\x000307";
- const ICOL_YELLOW = "\x000308";
- const ICOL_LGREEN = "\x000309";
- const ICOL_CYAN = "\x000310";
- const ICOL_LCYAN = "\x000311";
- const ICOL_LBLUE = "\x000312";
- const ICOL_PINK = "\x000313";
- const ICOL_GREY = "\x000314";
- const ICOL_LGREY = "\x000315";
- const ICOL = "\x0003";
- const ICOL_BOLD = "\x0002";
- const ICOL_ULINE = "\x0031";
- const RED = "[#FF0000]";
- const PINK = "[#FF1493]";
- const ORANGE = "[#FF8C00]";
- const YELLOW = "[#FFD700]";
- const PURPLE = "[#9400D3]";
- const GREEN = "[#32CD32]";
- const LBLUE = "[#1E90FF]";
- const BLUE = "[#4682B4]";
- const BROWN = "[#8B4513]";
- const WHITE = "[#FFFFFF]";
- const BLACK = "[#000000]";
- const GREY = "[#808080]";
- const MSG = "[#AFFF00]";
- const FBS_NICK = "AC"; // The name of the echo bot
- const FBS_BPASS = ""; // The NickServ password of the echo bot
- const FBS_SERVER = "94.23.157.172"; // The numerical ip of the irc server - this will join irc.nl.project-apollo.co.uk
- const FBS_PORT = 6667; // The port for that irc server
- const FBS_CHAN = "#TDCS"; // The channel that you wont your echo bot to join
- const FBS_CPASS = ""; // The password for that channel, if there isnt one leave it as "".{
- class FBSLIST
- {
- // This is how we are going to store the user level information for each nick currently on the channel
- Name = null;
- Level = 1;
- }
- function FBSLIST::AddNick( szNick, iAdmin )
- {
- Name = szNick;
- Level = iAdmin;
- }
- function ActivateEcho()
- {
- print( "Confirming echo bot details..." );
- FBS_BOT <- NewSocket( "FBSProcess" );
- FBS_BOT.Connect( FBS_SERVER, FBS_PORT );
- FBS_BOT.SetNewConnFunc( "FBSLogin" );
- print( "Bot details confirmed!" );
- FBS_NICKS <- array( 50, null );
- }
- function DisconnectBots()
- {
- print( "Disconnecting bot from IRC..." );
- FBS_BOT.Send( "QUIT " + FBS_NICK + "\n" );
- FBS_BOT.Delete();
- print( FBS_NICK + " has succesfully disconnected from IRC." );
- }
- function FBSLogin()
- {
- print( "Attempting to set user, nick and mode...." );
- // Set the bots name and real name
- FBS_BOT.Send( "USER " + FBS_NICK + " 0 * :Death City IRC BOT\n" );
- // Set the nick that the bot will use on the irc server
- FBS_BOT.Send( "NICK " + FBS_NICK + "\n" );
- // Set it so that the network classes the bot as a bot
- FBS_BOT.Send( "MODE " + FBS_NICK + " +B\n" );
- print( "Task completed successfully." );
- }
- function FBSProcess( sz )
- {
- // This function is used to process the raw data that the bot is recieving from the irc server
- local raw = split( sz, "\r\n" ), a, z = raw.len(), line;
- for ( a = 0; a < z; a++ )
- {
- line = raw[ a ];
- local FBS_PING = GetTok( line, " ", 1 ), FBS_EVENT = GetTok( line, " ", 2 ), FBS_CHANEVENT = GetTok( line, " ", 3 ),
- Count = NumTok( line, " " ), Nick, Command, Prefix, Text;
- // The most important thing is making sure that the bot stays connected to IRC
- if ( FBS_PING ) FBS_BOT.Send( "PONG " + FBS_PING + "\n" );
- if ( FBS_EVENT == "001" )
- {
- if ( FBS_BOT )
- {
- // Identify the bot with services, comment this line if its not registered
- FBS_BOT.Send( "PRIVMSG NickServ IDENTIFY " + FBS_BPASS + "\n" );
- // Set it so that the network classes the bot as a bot
- FBS_BOT.Send( "MODE " + FBS_NICK + " +B\n" );
- // Make the bot join the specified channel
- FBS_BOT.Send( "JOIN " + FBS_CHAN + " " + FBS_CPASS + "\n" );
- EchoMessage( ICOL_GREEN+ICOL_BOLD+">> GTX-Bot has successfully connected to #gtx." );
- Message( MSG+"--> GTX-Bot has now re-connected to Generation Trigger-X (GTX) Server." );
- // The bot now needs to collect information about users in the channel
- print( "Succesfully joined " + FBS_CHAN + "!" );
- }
- }
- else if ( FBS_EVENT == "353" ) FBSSortNicks( sz );
- else if ( ( FBS_EVENT == "MODE" ) || ( FBS_EVENT == "NICK" ) || ( FBS_EVENT == "JOIN" ) || ( FBS_EVENT == "PART" ) || ( FBS_EVENT == "QUIT" ) ) FBS_BOT.Send( "NAMES :" + FBS_CHAN + "\n" );
- if ( FBS_CHANEVENT == FBS_CHAN )
- {
- // Grab the nick
- Nick = GetTok( line, "!", 1 ).slice( 1 );
- // Figure out what the command is
- Command = GetTok( line, " ", 4 );
- // Figure out what prefix was used
- Prefix = Command.slice( 1, 2 );
- Command = Command.slice( 1 );
- // Figure out the text after the command
- if ( NumTok( line, " " ) > 4 ) Text = GetTok( line, " ", 5, Count );
- else Command = split( Command, "\r\n" )[ 0 ];
- // Parse the command
- /*
- if ( ( Prefix == "!" ) && ( Count > 4 ) ) FBSIrcCommand( Nick, Command, Text );
- else if ( ( Prefix == "!" ) && ( Count == 4 ) ) FBSIrcCommand( Nick, Command, null );
- */
- if (Nick && Command && Text) { FBSIrcCommand( Nick, Command, Text ); }
- else if (Nick && Command) { FBSIrcCommand( Nick, Command, null ); }
- }
- }
- }
- function LevelTag(lvl)
- {
- lvl = (lvl ? lvl:0);
- switch (lvl)
- {
- case 2:
- return "IRC=Mini-Moderator=";
- case 3:
- return "IRC=Moderator=";
- case 4:
- return "IRC=Admin=";
- case 5:
- return "IRC=Head Admin=";
- case 6:
- return "IRC=Owner=";
- default:
- return "IRC=User=";
- }
- }
- function lLevelTag(lvl) {
- lvl = (lvl ? lvl:0);
- switch (lvl) {
- case 2:
- return "7";
- case 3:
- return "9";
- case 4:
- return "6";
- case 5:
- return "10";
- case 6:
- return "4";
- default:
- return "5";
- }
- }
- function FBSIrcCommand( user, cmd, text )
- {
- // none of this needs to be touched, it is to do with getting channel levels
- local NickInfo = FindNick( user ), level, tLevel;
- if ( NickInfo ) level = NickInfo.Level.tointeger();
- //---------------------------------------------------------------------------
- if (cmd) {
- if (cmd.slice(0,1) == "." && cmd.len() > 1) {
- local msg = LevelTag(level) + " " + user + ": " + cmd.slice(1);
- if (text) msg = msg + " " + text;
- EchoMessage(ICOL_BOLD+lLevelTag(level) + msg);
- if (level == 6) Message(RED+msg);
- else if (level == 5) Message(BLUE+msg);
- else if (level == 4) Message(PURPLE+msg);
- else if (level == 3) Message(GREEN+msg);
- else if (level == 2) Message(ORANGE+msg);
- else Message(BROWN+msg);
- }
- }
- if ( cmd == "!say" )
- {
- if ( !text ) EchoMessage( "Error - Syntax: " + cmd + " <text> " );
- else
- {
- if ( level > 3 ) ::IbMessage( "* Admin " + user + ": " + text );
- else if ( level == 3 ) ::IbMessage( "* Moderator " + user + ": " + text );
- else ::IbMessage( user + ": " + text );
- }
- }
- else if ( cmd == "!me" )
- {
- if ( !text ) EchoMessage( "Error - Syntax: !" + cmd + " <text> " );
- else ::IbMessage( user + " " + text );
- }
- else if ( cmd == "!players" )
- {
- local plr, buffer = "", MAX_PLAYERS = GetMaxPlayers();
- for( local i=0; i < MAX_PLAYERS; ++i )
- {
- plr = FindPlayer( i );
- if ( plr ) buffer = buffer + " " + plr.Name + "[" + plr.ID + "]";
- }
- if ( buffer != "" ) EchoMessage( "Online Players: " + strip(buffer) );
- EchoMessage( "Total players: " + GetPlayers() );
- }
- else if ( ( cmd == "!admin" ) || ( cmd == "!admins" ) )
- {
- local a = 0, b = null;
- while ( a < GetMaxPlayers() )
- {
- local plr = GetPlayer( a );
- if ( plr )
- {
- local lvl = GetLevel( plr );
- if ( lvl >= 2 )
- {
- if ( b ) b = b + " - " + plr.Name + " ";
- else b = plr.Name + " ";
- }
- }
- a ++;
- }
- if ( b ) { EchoMessage( ICOL_BLUE + "*--> Admins Online: " + b ); }
- else EchoMessage( ICOL_RED + "No Admins Online." );
- }
- else if ( cmd == "!ping" )
- {
- if ( !text ) EchoMessage( "Error - Syntax: " + cmd + " <Nick/ID> " );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoMessage( "Invalid Player..." );
- IbMessage( "" + plr.Name + "'s Ping: " + plr.Ping + ". " );
- }
- }
- else if ( cmd == "!server" )
- {
- EchoMessage( ICOL_PURPLE + "Server Name: " + GetServerName() );
- EchoMessage( ICOL_ORANGE + "Game-Mode: " + GetGamemodeName() );
- EchoMessage( ICOL_BLACK + "Map: " + GetMapName() );
- EchoMessage( ICOL_PINK + "Player Slots: " + GetMaxPlayers() );
- }
- else if ( cmd == "!script" )
- {
- EchoMessage( ICOL_PURPLE + "Server Is Scripted By :- [MRDK]" );
- EchoMessage( ICOL_ORANGE + "Script Version: TDC v-0.4" );
- }
- else if ( cmd == "!country" )
- {
- if ( !text ) EchoMessage( "Error - !country <Nick/ID>." );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoMessasge( "Error: Invalid Player." );
- local IP = plr.IP;
- local country = geoip_country_name_by_addr(plr.IP);
- EchoMessage( "" + plr + "'s Country: " + country + ". [" + geoip_country_code_by_addr(plr.IP) + "]" );
- }
- }
- else if ( cmd == "!lvl" )
- {
- if ( !text ) EchoMessage( "Error - !lvl <Nick/ID>." );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) ), le = GetLevel( plr );
- if ( !plr ) EchoMessage( user, "Error: Invalid Player." );
- EchoMessage( "" + plr + "'s Level:[ " + GetLevel( plr ) + " ] Group:[ " + LevelTag( plr ) + " ]" );
- }
- }
- else if ( cmd == "!arm" )
- {
- if ( !text ) EchoMessage("Error - Syntax: " + cmd + " <Nick/ID>");
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoMessage("Error - Invalid Nick/ID");
- EchoMessage("["+plr.ID+"] "+plr+" Armour:[ "+plr.Armour+"'% ]");
- }
- }
- else if ( cmd == "!hp" )
- {
- if ( !text ) EchoMessage("Error - Syntax: " + cmd + " <Nick/ID>");
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoMessage("Error - Invalid Nick/ID");
- EchoMessage("["+plr.ID+"] "+plr+" Health:[ "+plr.Health+"'% ]");
- }
- }
- else if ( ( cmd == "!cmds" ) || ( cmd == "!commands" ) )
- {
- EchoMessage( ICOL_ORANGE + " !hp, !arm, !say, !me, !players, !admins, !script, !lvl, !ping, !server, !country ." );
- }
- // Admin Cmds
- else if ( ( cmd == "!acmds" ) || ( cmd == "!admincmds" ) )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else EchoNotice( user, ICOL_BLACK + " !exe, !getip, !ann, !freeze, !unfreeze, !annall, !slap, !drown, !kill, !mute" );
- }
- else if ( cmd == "!drown" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID> <Reason> ");
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoNotice( user, "Error - Unknown player." );
- else
- {
- local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
- if ( !msg ) EchoNotice( user, "Error - Invalid format." );
- else
- {
- EchoMessage( ICOL_BLACK + "Drowned Player:[ " + plr.Name + " ]. Reason:[ " + msg + " ]" );
- Message( "Admin " + user + " has drowned " + plr.Name + ". Reason: " + msg + "." );
- plr.Pos = Vector( 283.521 , -1574.3 , 7.19846 );
- }
- }
- }
- }
- else if ( cmd == "!kill" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID> <Reason> ");
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoNotice( user, "Error - Unknown player." );
- else
- {
- local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
- if ( !msg ) EchoNotice( user, "Error - Invalid format." );
- else
- {
- EchoMessage( ICOL_BLACK + "Killed Player:[ " + plr.Name + " ]. Reason:[ " + msg + " ]" );
- Message( "Admin " + user + " has killed " + plr.Name + ". Reason: " + msg + "." );
- plr.Pos = plr.Pos
- plr.Health = 0;
- }
- }
- }
- }
- else if ( cmd == "!slap" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoNotice( user, "Error - Invalid player." );
- IbMessage( "Admin " + user + " has slapped " + plr.Name + "." );
- plr.Health -= 20;
- }
- }
- else if ( cmd == "!ann" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID/all> <Message> ");
- else if (GetTok( text, " ", 1 ).tolower() =="all")
- {
- local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
- AnnounceAll( msg );
- EchoMessage( ICOL_BLACK + "Sent Announcement:[ " + msg + " ] to all players" );
- }
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoNotice( user, "Unknow player." );
- else
- {
- local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
- Announce( msg, plr, 3 );
- EchoMessage( ICOL_BLACK + "Sent Announcement:[ " + msg + " ] to:[ " + plr.Name + " ]" );
- }
- }
- }
- else if ( cmd == "!annall" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error Syntax: " + cmd + " <Message>");
- else
- {
- local msg = GetTok( text, " ", 2,NumTok( text, " "));
- AnnounceAll( text, 3);
- EchoMessage( ICOL_BLACK + " " + user + " Sent Announcement to all players in game. Message:[ " + text + " ]" );
- }
- }
- else if ( cmd == "!freeze" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID> <Reason> ");
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoNotice( user, "Error - Unknow player." );
- else
- {
- local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
- if ( !msg ) EchoNotice( user, "Error - Invalid format." );
- else
- {
- EchoMessage( ICOL_BLACK + "Freezed Player:[ " + plr.Name + " ]. Reason:[ " + msg + " ]" );
- Message( "Admin " + user + " has frozen " + plr.Name + ". Reason: " + msg + "." );
- plr.IsFrozen = true;
- }
- }
- }
- }
- else if ( cmd == "!mute" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error - Syntax: " + cmd + " <Nick/ID> <Reason> ");
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if (!plr) EchoNotice( user, " Error - Unknown player" );
- else
- {
- local msg = GetTok( text, " ", 2, NumTok( text, " " ) );
- if ( !msg ) EchoNotice( user, "Error - Invalid format." );
- else
- {
- EchoMessage( ICOL_BLACK + "Muted Player:[ " + plr.Name + " ]. Reason:[ " + msg + " ]" );
- Message( "Admin " + user + " has muted " + plr.Name + " ]. Reason: " + msg + "." );
- plr.IsMuted = true;
- }
- }
- }
- }
- else if ( cmd == "!unmute" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + "Error - Your level is not high enough to use that command." );
- else if ( !text ) EchoNotice( user, ICOL_RED + " Error - Syntax: !unmute <Nick/ID>" );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if (!plr) EchoNotice( user, " Error - Unknown Player" );
- else
- {
- EchoMessage( ICOL_BROWN + " Admin " + user + " has un-muted Player " + plr.Name + "." );
- Message( "Admin " + user + " has un-muted " + plr.Name + "." );
- plr.IsMuted = false;
- }
- }
- }
- else if ( cmd == "!unfreeze" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + " Error - Your level is not high enough." );
- else if ( !text ) EchoNotice( user, ICOL_RED + " Error - Syntax: !unfreeze <Nick/ID>" );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if (!plr) EchoNotice( user, " Error - Unknown Player" );
- else
- {
- EchoMessage( ICOL_BLUE + "Admin " + user + " has un-frozen " + plr.Name + "." );
- Message( " **Admin " + user + " has un-frozen " + plr.Name + "." );
- plr.IsFrozen = false;
- }
- }
- }
- else if( cmd == "!exe" )
- {
- if ( !text ) EchoMessage( ICOL_RED + "Error - Syntax: !exec <Squirrel code>" );
- else if( level < 6 ) EchoNotice( user, ICOL_RED + "You have to be an admin to use such commands." );
- else
- {
- try
- {
- local script = compilestring( text );
- if(script)
- {
- script();
- EchoMessage( "4 command executed successfully!" );
- }
- else EchoMessage( "4 error!" );
- }
- catch(e) EchoMessage( "Error:" + e );
- }
- }
- else if ( cmd == "!getip")
- {
- if ( !text ) EchoMessage( ICOL_RED + "Error - Syntax: !getip <Nick/ID>" );
- else if( level < 3 ) EchoNotice( user, ICOL_RED + "You have to be an admin to use such commands." );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if (!plr) EchoNotice( user, " Error - Unknown Player" );
- else
- {
- EchoNotice( user, ICOL_BLUE + " " + plr.Name + " IP:[ " + plr.IP + "]." );
- }
- }
- }
- }
- function EchoNotice( nick, text )
- {
- // Send A notice :)
- FBS_BOT.Send( "NOTICE " + nick + " " + text + "\n" );
- }
- function EchoMessage( text )
- {
- // This is used for events such as a player joining
- // EchoMessage( "** [" + player.ID + "] " + player + " has joined the server." );
- FBS_BOT.Send( "PRIVMSG " + FBS_CHAN + " " + text + "\n" );
- }
- /* The following functions below are to do with parsing nick information and levels
- DO NOT TOUCH ANYTHING BELOW THIS LINE.......EVER!
- */
- function FBSSortNicks( szList )
- {
- local a = NumTok( szList, " " );
- local NickList = GetTok( szList, " ", 6, a ), i = 1;
- FBS_NICKS <- array( 50, null );
- while( GetTok( NickList, " ", i ) != "366" )
- {
- local levelnick = GetTok( NickList, " ", i ), nick = levelnick.slice( 1 ), level = levelnick.slice( 0, 1 );
- if ( level == ":" ) { level = nick.slice( 0, 1 ); nick = nick.slice( 1 ); }
- if ( level == "+" ) AddNewNick( nick, 2 );
- else if ( level == "%" ) AddNewNick( nick, 3 );
- else if ( level == "@" ) AddNewNick( nick, 4 );
- else if ( level == "&" ) AddNewNick( nick, 5 );
- else if ( level == "~" ) AddNewNick( nick, 6 );
- else AddNewNick( nick, 1 );
- i ++;
- }
- }
- function AddNewNick( szName, iLevel )
- {
- local i = FindFreeNickSlot();
- if ( i != -1 )
- {
- FBS_NICKS[ i ] = FBSLIST();
- FBS_NICKS[ i ].AddNick( szName, iLevel );
- }
- }
- function FindFreeNickSlot()
- {
- for ( local i = 0; i < FBS_NICKS.len(); i++ )
- {
- if ( !FBS_NICKS[ i ] ) return i;
- }
- return -1;
- }
- function FindNick( szName )
- {
- for ( local i = 0; i < FBS_NICKS.len(); i++ )
- {
- if ( FBS_NICKS[ i ] )
- {
- if ( FBS_NICKS[ i ].Name == szName ) return FBS_NICKS[ i ];
- }
- }
- return null;
- }
Add Comment
Please, Sign In to add comment