Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
- {
- FBS_BOT <- NewSocket( "FBSProcess" );
- FBS_BOT.Connect( FBS_SERVER, FBS_PORT );
- FBS_BOT.SetNewConnFunc( "FBSLogin" );
- FBS_NICKS <- array( 50, null );
- }
- function DisconnectBots()
- {
- print( "Disconnected." );
- FBS_BOT.Send( "QUIT " + FBS_NICK + "\n" );
- FBS_BOT.Delete();
- }
- function ReconnectEcho()
- {
- print("-- Reconnecting Bots --");
- FBS_BOT.Send( "QUIT 4Reconnecting\n" );
- NewTimer("ActivateEcho",3000,1);
- UnloadIRCEcho();
- NewTimer( "LoadIRCEcho", 3000, 1 );
- FBS_BOT.Delete();
- }
- function FBSLogin()
- {
- SendSMsg( "USER " + FBS_NICK + " 0 * : " + FBS_NICK + " \n" );
- SendSMsg( "NICK " + FBS_NICK + "\n" );
- NewTimer( "SendSMsg", 2000, 1, "PRIVMSG NickServ IDENTIFY " + FBS_BPASS + "\n" );
- SendSMsg( "MODE " + FBS_NICK + " +B\n" );
- print("-- Echo Loaded --");
- NewTimer( "SendSMsg", 2000, 1, "JOIN " + FBS_CHAN + "\n" );
- NewTimer( "SendSMsg", 2000, 1, "JOIN #Blood-Madness.Admin dzmeh\n" );
- NewTimer( "SendSMsg", 2000, 1, "NS IDENTIFY " + FBS_BPASS + "\n" );
- }
- function SendSMsg( msg )
- {
- try
- {
- if ( FBS_BOT ) FBS_BOT.Send( msg );
- }
- catch(E)
- {
- print( "Error Sending a message to the socket: " + E );
- return 1;
- }
- }
- function FBSProcess( sz )
- {
- // This function is used to process the raw data that the bot is recieving from the irc server
- local FBS_PING = GetTok( sz, " ", 1 ), FBS_EVENT = GetTok( sz, " ", 2 ), FBS_CHANEVENT = GetTok( sz, " ", 3 ), Count = NumTok( sz, " " );
- local 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 == "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( sz, "!", 1 ).slice( 1 );
- // Figure out what the command is
- Command = GetTok( sz, " ", 4 );
- // Figure out what prefix was used
- Prefix = Command.slice( 1, 2 );
- Command = Command.slice( 2 );
- // Figure out the text after the command
- if ( NumTok( sz, " " ) > 4 ) Text = GetTok( sz, " ", 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 );
- }
- }
- 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 ( text ) text = text.slice( 0, text.len() - 2 );
- //---------------------------------------------------------------------------
- // these are two example commands that you can base your other commands off.
- if ( cmd == "say" )
- {
- if ( !text ) EchoMessage( "3Error: !" + cmd + " <text>" );
- else
- {
- if ( level == 2 ) EchoMessage( "5** Voice " + user + ": " + text ), ClientMessageToAll( "** Voice " + user + ": " + text, 999, 999, 999 );
- else if ( level == 3 ) EchoMessage( "5** Moderator " + user + ": " + text ), ClientMessageToAll( "** Moderator " + user + ": " + text, 999, 999, 999 );
- else if ( level == 4 ) EchoMessage( "5** Admin " + user + ": " + text ), ClientMessageToAll( "** Admin " + user + ": " + text, 999, 999, 999 );
- else if ( level == 5 ) EchoMessage( "5** Manager " + user + ": " + text ), ClientMessageToAll( "** Manager " + user + ": " + text, 999, 999, 999 );
- else if ( level == 6 ) EchoMessage( "5** Owner " + user + ": " + text ), ClientMessageToAll( "** Owner " + user + ": " + text, 999, 999, 999 );
- else EchoMessage( "5** User " + user + ": " + text ), ClientMessageToAll( "** User " + user + ": " + text, 999, 999, 999 );
- }
- }
- else if ( cmd == "commands" )
- {
- if ( level == 2 ) EchoNotice( user, "4[Commands]5 !say !players !score !stats !loc !prank !rank !ping !info !hp !admin !level !forum !hoston" );
- else if ( level == 3 ) EchoNotice( user, "4[Commands]5 !say !players !score !stats !loc !prank !rank !ping !info !hp !admin !level !forum !hoston !kick !setweather !start !end !pause !unpause !getip !alias !freeze !unfreeze !ann !drown !warn !settime !mute !unmute" );
- else if ( level == 4 ) EchoNotice( user, "4[Commands]5 !say !players !score !stats !loc !prank !rank !ping !info !hp !admin !level !forum !hoston !kick !setweather !start !end !pause !unpause !getip !ipban !subnetban !unban !banip !alias !unbansubnet !freeze !unfreeze !ann !drown !warn !settime !mute !unmute !baninfo" );
- else if ( level > 4 ) EchoNotice( user, "4[Commands]5 !say !players !score !stats !loc !prank !rank !ping !info !hp !admin !level !forum !hoston !kick !setweather !start !end !pause !unpause !getip !ipban !subnetban !unban !unbansubnet !banip !alias !setlevel !freeze !unfreeze !ann !drown !warn !settime !mute !unmute !setservername !setserverpass !getpassword !transferacc !raccount" );
- else ::EchoNotice( user, "4[Commands]5 !say !players !score !stats !loc !prank !rank !ping !info !hp !admin !level !forum !hoston" );
- }
- else EchoMessage( "12Error: I don't know that command." );
- // End of cmds
- }
- function EchoNotice( nick, text )
- {
- FBS_BOT.Send( "NOTICE " + nick + " " + 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;
- }
- 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();
- }
Add Comment
Please, Sign In to add comment