Guest User

Untitled

a guest
Apr 26th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 KB | None | 0 0
  1. class FBSLIST
  2. {
  3. // This is how we are going to store the user level information for each nick currently on the channel
  4. Name = null;
  5. Level = 1;
  6. }
  7.  
  8. function FBSLIST::AddNick( szNick, iAdmin )
  9. {
  10. Name = szNick;
  11. Level = iAdmin;
  12. }
  13.  
  14. function ActivateEcho()
  15. {
  16. FBS_BOT <- NewSocket( "FBSProcess" );
  17. FBS_BOT.Connect( FBS_SERVER, FBS_PORT );
  18. FBS_BOT.SetNewConnFunc( "FBSLogin" );
  19. FBS_NICKS <- array( 50, null );
  20. }
  21.  
  22. function DisconnectBots()
  23. {
  24. print( "Disconnected." );
  25.  
  26. FBS_BOT.Send( "QUIT " + FBS_NICK + "\n" );
  27. FBS_BOT.Delete();
  28. }
  29.  
  30. function ReconnectEcho()
  31. {
  32. print("-- Reconnecting Bots --");
  33. FBS_BOT.Send( "QUIT 4Reconnecting\n" );
  34. NewTimer("ActivateEcho",3000,1);
  35. UnloadIRCEcho();
  36. NewTimer( "LoadIRCEcho", 3000, 1 );
  37. FBS_BOT.Delete();
  38. }
  39.  
  40. function FBSLogin()
  41. {
  42. SendSMsg( "USER " + FBS_NICK + " 0 * : " + FBS_NICK + " \n" );
  43. SendSMsg( "NICK " + FBS_NICK + "\n" );
  44. NewTimer( "SendSMsg", 2000, 1, "PRIVMSG NickServ IDENTIFY " + FBS_BPASS + "\n" );
  45. SendSMsg( "MODE " + FBS_NICK + " +B\n" );
  46. print("-- Echo Loaded --");
  47. NewTimer( "SendSMsg", 2000, 1, "JOIN " + FBS_CHAN + "\n" );
  48. NewTimer( "SendSMsg", 2000, 1, "JOIN #Blood-Madness.Admin dzmeh\n" );
  49. NewTimer( "SendSMsg", 2000, 1, "NS IDENTIFY " + FBS_BPASS + "\n" );
  50. }
  51.  
  52. function SendSMsg( msg )
  53. {
  54. try
  55. {
  56. if ( FBS_BOT ) FBS_BOT.Send( msg );
  57. }
  58. catch(E)
  59. {
  60. print( "Error Sending a message to the socket: " + E );
  61. return 1;
  62. }
  63. }
  64.  
  65. function FBSProcess( sz )
  66. {
  67. // This function is used to process the raw data that the bot is recieving from the irc server
  68. local FBS_PING = GetTok( sz, " ", 1 ), FBS_EVENT = GetTok( sz, " ", 2 ), FBS_CHANEVENT = GetTok( sz, " ", 3 ), Count = NumTok( sz, " " );
  69. local Nick, Command, Prefix, Text;
  70.  
  71. // The most important thing is making sure that the bot stays connected to IRC
  72. if ( FBS_PING ) FBS_BOT.Send( "PONG " + FBS_PING + "\n" );
  73.  
  74. if ( FBS_EVENT == "353" ) FBSSortNicks( sz );
  75. else if ( ( FBS_EVENT == "MODE" ) || ( FBS_EVENT == "NICK" ) || ( FBS_EVENT == "JOIN" ) || ( FBS_EVENT == "PART" ) || ( FBS_EVENT == "QUIT" ) ) FBS_BOT.Send( "NAMES :" + FBS_CHAN + "\n" );
  76. if ( FBS_CHANEVENT == FBS_CHAN )
  77. {
  78. // Grab the nick
  79. Nick = GetTok( sz, "!", 1 ).slice( 1 );
  80. // Figure out what the command is
  81. Command = GetTok( sz, " ", 4 );
  82. // Figure out what prefix was used
  83. Prefix = Command.slice( 1, 2 );
  84. Command = Command.slice( 2 );
  85.  
  86. // Figure out the text after the command
  87. if ( NumTok( sz, " " ) > 4 ) Text = GetTok( sz, " ", 5, Count );
  88. else Command = split( Command, "\r\n" )[ 0 ];
  89.  
  90. // Parse the command
  91. if ( ( Prefix == "!" ) && ( Count > 4 ) ) FBSIrcCommand( Nick, Command.tolower(), Text );
  92. else if ( ( Prefix == "!" ) && ( Count == 4 ) ) FBSIrcCommand( Nick, Command.tolower(), null );
  93. }
  94. }
  95.  
  96. function FBSIrcCommand( user, cmd, text )
  97. {
  98. // none of this needs to be touched, it is to do with getting channel levels
  99. local NickInfo = FindNick( user ), level, tLevel;
  100.  
  101. if ( NickInfo ) level = NickInfo.Level.tointeger();
  102. if ( text ) text = text.slice( 0, text.len() - 2 );
  103. //---------------------------------------------------------------------------
  104.  
  105. // these are two example commands that you can base your other commands off.
  106.  
  107. if ( cmd == "say" )
  108. {
  109. if ( !text ) EchoMessage( "3Error: !" + cmd + " <text>" );
  110. else
  111. {
  112. if ( level == 2 ) EchoMessage( "5** Voice " + user + ": " + text ), ClientMessageToAll( "** Voice " + user + ": " + text, 999, 999, 999 );
  113. else if ( level == 3 ) EchoMessage( "5** Moderator " + user + ": " + text ), ClientMessageToAll( "** Moderator " + user + ": " + text, 999, 999, 999 );
  114. else if ( level == 4 ) EchoMessage( "5** Admin " + user + ": " + text ), ClientMessageToAll( "** Admin " + user + ": " + text, 999, 999, 999 );
  115. else if ( level == 5 ) EchoMessage( "5** Manager " + user + ": " + text ), ClientMessageToAll( "** Manager " + user + ": " + text, 999, 999, 999 );
  116. else if ( level == 6 ) EchoMessage( "5** Owner " + user + ": " + text ), ClientMessageToAll( "** Owner " + user + ": " + text, 999, 999, 999 );
  117. else EchoMessage( "5** User " + user + ": " + text ), ClientMessageToAll( "** User " + user + ": " + text, 999, 999, 999 );
  118. }
  119. }
  120. else if ( cmd == "commands" )
  121. {
  122. if ( level == 2 ) EchoNotice( user, "4[Commands]5 !say !players !score !stats !loc !prank !rank !ping !info !hp !admin !level !forum !hoston" );
  123. 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" );
  124. 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" );
  125. 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" );
  126. else ::EchoNotice( user, "4[Commands]5 !say !players !score !stats !loc !prank !rank !ping !info !hp !admin !level !forum !hoston" );
  127. }
  128.  
  129. else EchoMessage( "12Error: I don't know that command." );
  130.  
  131. // End of cmds
  132. }
  133.  
  134.  
  135. function EchoNotice( nick, text )
  136. {
  137. FBS_BOT.Send( "NOTICE " + nick + " " + text + "\n" );
  138. }
  139.  
  140. /* The following functions below are to do with parsing nick information and levels
  141. DO NOT TOUCH ANYTHING BELOW THIS LINE.......EVER!
  142. */
  143.  
  144. function FBSSortNicks( szList )
  145. {
  146. local a = NumTok( szList, " " );
  147. local NickList = GetTok( szList, " ", 6, a ), i = 1;
  148.  
  149. FBS_NICKS <- array( 50, null );
  150.  
  151. while( GetTok( NickList, " ", i ) != "366" )
  152. {
  153. local levelnick = GetTok( NickList, " ", i ), nick = levelnick.slice( 1 ), level = levelnick.slice( 0, 1 );
  154.  
  155. if ( level == ":" ) { level = nick.slice( 0, 1 ); nick = nick.slice( 1 ); }
  156. if ( level == "+" ) AddNewNick( nick, 2 );
  157. else if ( level == "%" ) AddNewNick( nick, 3 );
  158. else if ( level == "@" ) AddNewNick( nick, 4 );
  159. else if ( level == "&" ) AddNewNick( nick, 5 );
  160. else if ( level == "~" ) AddNewNick( nick, 6 );
  161. else AddNewNick( nick, 1 );
  162. i ++;
  163. }
  164. }
  165.  
  166. function AddNewNick( szName, iLevel )
  167. {
  168. local i = FindFreeNickSlot();
  169.  
  170. if ( i != -1 )
  171. {
  172. FBS_NICKS[ i ] = FBSLIST();
  173. FBS_NICKS[ i ].AddNick( szName, iLevel );
  174. }
  175. }
  176.  
  177. function FindFreeNickSlot()
  178. {
  179. for ( local i = 0; i < FBS_NICKS.len(); i++ )
  180. {
  181. if ( !FBS_NICKS[ i ] ) return i;
  182. }
  183. return -1;
  184. }
  185.  
  186. function FindNick( szName )
  187. {
  188. for ( local i = 0; i < FBS_NICKS.len(); i++ )
  189. {
  190. if ( FBS_NICKS[ i ] )
  191. {
  192. if ( FBS_NICKS[ i ].Name == szName ) return FBS_NICKS[ i ];
  193. }
  194. }
  195. return null;
  196. }
  197.  
  198. function GetTok(string, separator, n, ...)
  199. {
  200. local m = vargv.len() > 0 ? vargv[0] : n,
  201. tokenized = split(string, separator),
  202. text = "";
  203.  
  204. if (n > tokenized.len() || n < 1) return null;
  205. for (; n <= m; n++)
  206. {
  207. text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
  208. }
  209. return text;
  210. }
  211.  
  212. function NumTok(string, separator)
  213. {
  214. local tokenized = split(string, separator);
  215. return tokenized.len();
  216. }
Add Comment
Please, Sign In to add comment