Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // IRC
- const FBS_NICK = "VG4L"; // The name of the echo bot
- const FBS_BPASS = "killer"; // 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 = "#VG"; // 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 * :VG training server echo 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" );
- // 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
- // Parse the command
- /*
- if ( ( Prefix == "!" ) && ( Count > 4 ) ) FBSIrcCommand( Nick, Command.tolower(), Text );
- else if ( ( Prefix == "!" ) && ( Count == 4 ) ) FBSIrcCommand( Nick, Command.tolower(), null );
- */
- if (Nick && Command && Text) { FBSIrcCommand( Nick, Command, Text ); }
- else if (Nick && Command) { FBSIrcCommand( Nick, Command, null ); }
- }
- }
- }
- function LevelTag1(lvl) {
- lvl = (lvl ? lvl:0);
- switch (lvl) {
- case 2:
- return "V.I.P";
- case 3:
- return "IRC-Moderator";
- case 4:
- return "IRC-Admin";
- case 5:
- return "IRC-Manager";
- case 6:
- return "IRC-Owner";
- default:
- return "User";
- }
- }
- function lLevelTag(lvl) {
- lvl = (lvl ? lvl:0);
- switch (lvl) {
- case 2:
- return "11";
- case 3:
- return "7";
- case 4:
- return "3";
- case 5:
- return "4";
- case 6:
- return "12";
- default:
- return "5";
- }
- }
- function FBSIrcCommand( user, cmd, text )
- {
- local NickInfo = FindNick( user ), level, tLevel, p;
- if ( NickInfo ) level = NickInfo.Level.tointeger();
- if (cmd)
- {
- if (cmd.slice(0,1) == "." && cmd.len() > 1)
- {
- local msg = "=> (" + LevelTag1(level) + ")" + user + ": " + cmd.slice(1);
- if (text) msg = msg + " " + text;
- EchoMessage(lLevelTag(level) + msg);
- Message(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_LGREEN + "Map: " + GetMapName() );
- EchoMessage( ICOL_PINK + "Player Slots: " + GetMaxPlayers() );
- }
- else if ( cmd == "!script" )
- {
- EchoMessage( ICOL_PURPLE + "Server by Thompson " );
- EchoMessage( ICOL_ORANGE + "Version:VG 0.1" );
- }
- 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 ." );
- }
- else if ( ( cmd == "!ircrules" ) || ( cmd == "!ircrules" ) )
- {
- EchoMessage( ICOL_ORANGE + " No flaming, no spamming, no unban requesting, no level requesting ." );
- }
- /// 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_LGREEN + " !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_LGREEN + "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_LGREEN + "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_LGREEN + "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, 0 );
- EchoMessage( ICOL_LGREEN + "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, 0);
- EchoMessage( ICOL_LGREEN + " " + 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_LGREEN + "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_LGREEN + "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 == "!kick" )
- {
- if ( level < 3 ) EchoNotice( user, ICOL_RED + " Error - Your level is not high enough." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error: Syntax, " + cmd + " <Nick/ID> <Reason>" );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoNotice( user, ICOL_RED + "Invalid Player." );
- else
- {
- local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
- if ( reason == null ) reason = "None";
- else
- {
- EchoMessage( ICOL_BLUE + "Admin " + user + " has kicked " + plr.Name + " Reason:[ " + reason + " ]." );
- Message( " ** Admin " + user + " has kicked " + plr.Name + " Reason:[ " + reason + " ]." );
- KickPlayer( plr );
- }
- }
- }
- }
- else if ( cmd == "!ban" )
- {
- if ( level < 4 ) EchoNotice( user, ICOL_RED + " Error - Your level is not high enough." );
- else if ( !text ) EchoNotice( user, ICOL_RED + "Error: Syntax, " + cmd + " <Nick/ID> <Reason>" );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) PrivMessage( "Invalid Player Nick / ID!", player );
- else
- {
- local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
- if ( reason == null ) reason = "None";
- else
- {
- QuerySQL( db, "INSERT INTO Bans ( Name, IP, Admin, Reason ) VALUES ( '" + player.Name + "', '" + player.IP + "', '" + user + "', '" + reason + "' )" );
- EchoMessage( "** Admin " + admin + " banned " + player.Name + " Reason: " + reason );
- Message( "** Admin " + admin + " banned " + player.Name + " Reason: " + reason );
- KickPlayer( player );
- }
- }
- }
- }
- 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" );
- }
- function NewsMessage( text )
- {
- ClientMessageToAll( text, 255, 255, 0 );
- }
- /* 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement