Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Irc Echo Script
- by megdaOnE
- */
- //---- Irc Data ----
- const BotName = "AOSB";
- const BotPass = "Admin";
- const IRCServerIP = "85.17.189.153";
- const IRCServerPort = 6667;
- const EchoChannel = "#asdafd";
- const EchoPass = "";
- const USER = 1;
- const VOICE = 2;
- const HALFOP = 3;
- const OP = 4;
- const SOP = 5;
- const OWNER = 6;
- local IRCNicks = {};
- //---- Functions ----
- function LoadIRCEcho()
- {
- IRCBot <- NewSocket( "IRCProcess" );
- IRCBot.Connect( IRCServerIP, IRCServerPort );
- IRCBot.SetNewConnFunc( "IRCLogin" );
- }
- function IRCProcess( Data )
- {
- local params = split( Data, " " );
- local Count = params.len(), Nick, Cmd, Prefix, Channel = EchoChannel;
- if ( params[ 0 ] == "PING" ) { SendSMsg( "PONG " + params[ 1 ] + "\n" ); SendSMsg( "NAMES :" + EchoChannel + "\n" ); }
- if ( params[ 1 ] == "353" ) IRCSaveNicks( Data );
- else if ( params[ 1 ] == "MODE" || params[ 1 ] == "NICK" || params[ 1 ] == "JOIN" || params[ 1 ] == "PART" || params[ 1 ] == "QUIT" ) SendSMsg( "NAMES :" + EchoChannel + "\n" );
- if ( params[ 1 ] == "PRIVMSG" && params[ 2 ].tolower() == Channel.tolower() )
- {
- if ( params[ 2 ].find( "#" ) == null ) return null;
- else
- {
- Nick = split( Data, "!" )[ 0 ].slice( 1 );
- Cmd = params[ 3 ];
- Prefix = Cmd.slice( 1, 2 );
- Cmd = Cmd.slice( 2 ).tolower();
- if ( Count > 4 && Prefix == "!" ) IRCCommands( Nick, Cmd, Data.slice( Data.find( Cmd ) + ( Cmd.len() + 1 ) ) );
- else if ( Count == 4 && Prefix == "!" ) IRCCommands( Nick, split( Cmd, "\r\n" )[ 0 ], null );
- }
- }
- else if ( params[ 1 ] == "KICK" && params[ 2 ].tolower() == Channel.tolower() ) SendSMsg( "JOIN " + Channel + " " + EchoPass + "\n" );
- else if ( params[ 1 ] == "001" )
- {
- SendSMsg( "PRIVMSG NICKSERV IDENTIFY " + BotPass + "\n" );
- SendSMsg( "JOIN " + EchoChannel + " " + EchoPass + "\n" );
- }
- }
- function IRCLogin()
- {
- SendSMsg( "USER " + BotName + " 0 * : " + BotName + " \n" );
- SendSMsg( "NICK " + BotName + "\n" );
- SendSMsg( "PRIVMSG NickServ IDENTIFY " + BotPass + "\n" );
- SendSMsg( "MODE " + BotName + " +B\n" );
- }
- function EchoMessage( text )
- {
- SendSMsg( "PRIVMSG " + EchoChannel + " " + text + "\n" );
- }
- function EMessage( text )
- {
- EchoMessage( text );
- Message( text.slice( 3 ) );
- }
- /*function EMessage( text, ... )
- {
- EchoMessage( text );
- if ( vargv.len() < 1 ) Message( text.slice( 3 ) );
- else Message( text.slice( 3 ), vargv[ 0 ] );
- }*/
- function UnloadIRCEcho()
- {
- if ( IRCBot )
- {
- SendSMsg( "QUIT " + BotName + "\n" );
- IRCBot.Delete();
- }
- }
- function SendSMsg( msg )
- {
- try
- {
- if ( IRCBot ) IRCBot.Send( msg );
- }
- catch(E)
- {
- print( "Error Sending a message to the socket: " + E );
- return 1;
- }
- }
- function IRCCommands( Nick, cmd, text )
- {
- local UserInfo, level, params;
- if ( !IRCNicks.rawin( Nick ) ) { IRCNewNick( Nick, 1 ); level = 1; }
- else { UserInfo = IRCNicks[ Nick ]; level = UserInfo.Level.tointeger(); }
- if ( text ) text = text.slice( 0, text.len() - 2 );
- if ( cmd == "say" )
- {
- if ( !text ) EchoMessage( "**4 Error - Correct Syntax:5 !" + cmd + " <Text>" );
- else EMessage( "12>> IRC: [" + GetIRCLevel( level ) + "] " + Nick + ": " + text + "." );
- }
- else if ( cmd == "ping" )
- {
- if ( !text ) EchoMessage( "**4 Error - Correct Syntax:5 !" + cmd + " <nick/id>" );
- {
- local param = split( text, " " ), plr = GetPlayer( param[ 0 ] );
- if ( !plr ) EchoMessage( "4[Error] >> " + param[ 0 ] + " isn't connected." );
- else EchoMessage( "7>> Ping " + plr.Name + " - " + plr.Ping + "." );
- }
- }
- else if ( cmd == "players" )
- {
- local b = null;
- for ( local a = 0; a < GetMaxPlayers(); a ++ )
- {
- local plr = FindPlayer( a );
- if ( plr )
- {
- if ( b ) b = b + " - 5" + plr.Name + " 14 [" + plr.ID + "]";
- else b = plr.Name + " 14[" + plr.ID + "]";
- }
- }
- if ( b ) EchoMessage( "**2 Players Online: 5" + b );
- else EchoMessage( "5There Aren't Players Online." );
- }
- else if ( cmd == "admins" )
- {
- local b = null;
- for ( local a = 0; a < GetMaxPlayers(); a ++ )
- {
- local plr = FindPlayer( a );
- if ( plr )
- {
- if ( GetPlayerLevel( plr ) >= 6 )
- {
- if ( b ) b = b + " - 13" + plr.Name + " 12[ " + LevelTag( GetPlayerLevel( plr ) ) + " ]";
- else b = plr.Name + " 12[ " + LevelTag( GetPlayerLevel( plr ) ) + " ]";
- }
- }
- }
- if ( b ) EchoMessage( "7>> Admins's: 13" + b );
- else EchoMessage( "**5 No Admins Online." );
- }
- else if ( cmd == "kick" )
- {
- if ( level < 4 ) EchoMessage( "4>> Only players with level 4 [ " + GetIRCLevel( 4 ) + " ] or high, have acces to this command." );
- else if ( !text ) EchoMessage( "6[Syntax] - The correct use: /c " + cmd + " <nick/id> <reason>." );
- else
- {
- local txt = NumTok( text, " " );
- if ( txt < 2 ) EchoMessage( "6[Syntax] - The correct use: /c " + cmd + " <nick/id> <reason>." );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoMessage( "6[Error] - Invalid nick/id, unknown player." );
- else
- {
- Message( "12>> IRC Admin " + Nick + " Kicked: " + plr.Name + ", ID: " + plr.ID + ", Reason:[ " + GetTok( text, " ", 2, txt ) + " ]." );
- KickPlayer( plr );
- }
- }
- }
- }
- else if ( cmd == "ban" )
- {
- if ( level < 5 ) EchoMessage( "4>> Only players with level 5 [ " + GetIRCLevel( 5 ) + " ] or high, have acces to this command." );
- else if ( !text ) EchoMessage( "6[Syntax] - The correct use: /c " + cmd + " <nick/id> <reason>." );
- else
- {
- local txt = NumTok( text, " " );
- if ( txt < 2 ) EchoMessage( "6[Syntax] - The correct use: /c " + cmd + " <nick/id> <reason>." );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoMessage( "6[Error] - Invalid nick/id, unknown player." );
- else
- {
- QuerySQL( SQLDataBase, format( "REPLACE INTO Banneds ( IP, Name, User, Data, ByAdmin, Reason ) VALUES ( '%s', '%s', '%s', '%s', '%s', '%s' )", plr.IP, plr.Name.tolower(), plr.Name, GetFullTime(), Nick , GetTok( text, " ", 2, txt ) ) );
- EMessage( "12>> IRC Admin " + Nick + " Banned: " + plr.Name + ", ID: " + plr.ID + ", Reason:[ " + GetTok( text, " ", 2, txt ) + " ]." );
- KickPlayer( plr );
- }
- }
- }
- }
- else if ( cmd == "setlevel" )
- {
- if ( level < 6 ) EchoMessage( "4>> Only players with level 6 [ " + GetIRCLevel( 6 ) + " ] or high, have acces to this command." );
- else if ( !text ) EchoMessage( "6[Syntax] >> The correct use: " + cmd + " <nick/id> <level>." );
- else
- {
- local txt = NumTok( text, " " );
- if ( txt < 2 ) EchoMessage( "6[Syntax] >> The correct use: " + cmd + " <nick/id> <level>." );
- else
- {
- local plr = GetPlayer( GetTok( text, " ", 1 ) );
- if ( !plr ) EchoMessage( "6[Error] - Invalid Nick/ID, unknown player." );
- else if ( !GetPlayerLevel( plr ) ) EchoMessage( "6[Error] - " + plr.Name + " not registered!" );
- else
- {
- local lvl = GetTok( text, " ", 2, txt );
- if ( !IsNum( lvl ) ) EchoMessage( "6[Error] - Invalid level, type numbers to level." );
- else
- {
- SetPlayerLevel( plr, lvl.tointeger() );
- EMessage( "12>> IRC Admin " + Nick + " set " + plr.Name + "'s level administration to [ " + lvl.tointeger() + " ] [ " + LevelTag( lvl.tointeger() ) + " ]." );
- }
- }
- }
- }
- }
- else if ( cmd == "restart" )
- {
- if ( level >= OP ) { EchoMessage( COL_RED + "***Restarting Echo Bot please wait some seconds***" ); NewTimer( "Reconnect", 1000, 1 ); }
- else EchoMessage( COL_RED + "Error - You don't have the needed level to restart the echo bot" );
- }
- }
- function IRCSaveNicks( List )
- {
- local a = NumTok( List, " " ), NickList = GetTok( List, " ", 6, a ), i = 1;
- local Nicks = split( NickList, " " );
- while( Nicks[ i-1 ] != "366" )
- {
- local nick = Nicks[ i-1 ].slice( 1 ), level = Nicks[ i-1 ].slice( 0, 1 );
- if ( level == ":" ) { level = nick.slice( 0, 1 ); nick = nick.slice( 1 ); }
- if ( level == "+" ) IRCNewNick( nick, 2 );
- else if ( level == "%" ) IRCNewNick( nick, 3 );
- else if ( level == "@" ) IRCNewNick( nick, 4 );
- else if ( level == "&" ) IRCNewNick( nick, 5 );
- else if ( level == "~" ) IRCNewNick( nick, 6 );
- else IRCNewNick( Nicks[ i-1 ], 1 );
- i ++;
- }
- }
- function IRCNewNick( Name, Level )
- {
- IRCNicks[ Name ] <- IRCNickz();
- IRCNicks[ Name ].SaveNickInfo( Name, Level );
- }
- class IRCNickz
- {
- Name = null;
- Level = 1;
- }
- function IRCNickz::SaveNickInfo( Nick, IRCLevel )
- {
- Name = Nick;
- Level = IRCLevel;
- }
- function GetIRCLevel( Level )
- {
- local Name = "User";
- switch( Level )
- {
- case 1:
- Name = "User";
- break;
- case 2:
- Name = "Member";
- break;
- case 3:
- Name = "Moderator";
- break;
- case 4:
- Name = "Admin";
- break;
- case 5:
- Name = "Management";
- break;
- case 6:
- Name = "Owner Server";
- break;
- }
- return Name;
- }
- function Reconnect()
- {
- UnloadIRCEcho();
- NewTimer( "LoadIRCEcho", 1600, 1 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement