Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Killers Online By hotdogcat
- */
- const ICOL_WHITE = "0";
- const ICOL_BLACK = "1";
- const ICOL_BLUE = "2";
- const ICOL_GREEN = "3";
- const ICOL_RED = "4";
- const ICOL_BROWN = "5";
- const ICOL_PURPLE = "6";
- const ICOL_ORANGE = "7";
- const ICOL_YELLOW = "8";
- const ICOL_LGREEN = "9";
- const ICOL_CYAN = "10";
- const ICOL_LCYAN = "11";
- const ICOL_LBLUE = "12";
- const ICOL_PINK = "13";
- const ICOL_GREY = "14";
- const ICOL_LGREY = "15";
- print( "Echo Loaded" );
- /*
- Squirrel IRC Bot - Version 1
- */
- const FBS_NICK = "LA";
- const FBS_BPASS = "";
- const FBS_SERVER = "91.121.134.5";
- const FBS_PORT = 6667;
- const FBS_CHAN = "#LA";
- const FBS_CPASS = "t"; // 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 * :[RD]Latino America\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 );
- 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.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 LevelTag(lvl) {
- lvl = (lvl ? lvl:0);
- switch (lvl) {
- case 2:
- return "Usuario";
- case 3:
- return "VIP";
- case 4:
- return "Moderador";
- case 5:
- return "Admin";
- case 6:
- return "Jefe";
- default:
- return "Major";
- }
- }
- 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 )
- {
- // none of this needs to be touched, it is to do with getting channel levels
- local NickInfo = FindNick( user ), level, tLevel;
- local s = 0, plr;
- if ( text ) { s = NumTok( text, " " ); plr = FindPlayer( text ); }
- if ( NickInfo ) level = NickInfo.Level.tointeger();
- //---------------------------------------------------------------------------
- if (cmd) {
- if (cmd.slice(0,1) == "." && cmd.len() > 1)
- {
- local msg = "" + user + ": " + cmd.slice(1);
- if (text) msg = msg + " " + text;
- EchoMessage("[IRC] "+msg+"");
- Message("[#0000CC][IRC] [#ffffff]"+msg);
- print("[IRC]"+msg)
- }
- }
- // these are two example commands that you can base your other commands off.
- else if ( cmd == "!players" )
- {
- local b = null, c = false;
- for ( local count = GetPlayers(), a = 0, plr; count && a < GetMaxPlayers(); a++ )
- {
- if ( !( plr = FindPlayer( a ) ) ) continue;
- if ( plr )
- {
- if ( b ) b=b+", 4["+plr.ID+"] 14"+plr.Name
- else b = "4["+plr.ID+"] 14"+plr.Name
- count--;
- c = true;
- }
- }
- if ( c == true ) EchoMessage( "2> 1Players: 1[" + GetPlayers() + "/" + GetMaxPlayers() + "] " + " - " + b );
- else EchoMessage( "1> Players: [ There are no players ]" );
- }
- }
- //============================= FUNCIONES ====================================//
- function EMessage( text )
- {
- Message( text );
- EchoMessage( text );
- }
- function EchoMessage( text )
- {
- FBS_BOT.Send( "PRIVMSG " + FBS_CHAN + " " + text + "\n" );
- }
- function EchoNotice( nick, text )
- {
- FBS_BOT.Send( "NOTICE " + nick + " " + text + "\n" );
- }
- 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;
- }
- function CmdLevelCheck( plrlvl, lvl )
- {
- if ( plrlvl >= lvl ) return true;
- else EchoMessage( "Error, No lvl" );
- }
- function CmdIRCLevel( cmd )
- {
- local cmd = GetTok( cmd, "!", 1 );
- return ReadIniInteger( "Commands.ini", "IRC", cmd );
- }
- function GetTok(string, separator, n, ...)
- {
- local m = vargv.len() > 0 ? vargv[0] : n,
- tokenized = split(string, separator),
- text = "";
- if (n > tokenized.len() || n < 1) return null;
- for (; n <= m; n++)
- {
- text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
- }
- return text;
- }
- function NumTok(string, separator)
- {
- local tokenized = split(string, separator);
- return tokenized.len();
- local s = split(string, separator);
- return s.len();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement