Advertisement
Guest User

Untitled

a guest
May 15th, 2017
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* $File: chatsocket.as $
  2.  * $Author: Nucleus $
  3.  * $Date: 1/2/2006 17:06:28 $
  4.  * $Revision: 1.0.0.3 $
  5.  *
  6.  * Copyright (C) 2006  Net-Bits.Net
  7.  *
  8.  * Contact: nucleusae@gmail.com
  9.  *
  10.  *  This library is free software; you can redistribute it and/or
  11.  *  modify it under the terms of the GNU Lesser General Public
  12.  *  License as published by the Free Software Foundation; either
  13.  *  version 2.1 of the License, or (at your option) any later version.
  14.  *
  15.  *  This library is distributed in the hope that it will be useful,
  16.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.  *  Lesser General Public License for more details.
  19.  *
  20.  *  You should have received a copy of the GNU Lesser General Public
  21.  *  License along with this library; if not, write to the Free Software
  22.  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  23.  *  02111-1307  USA.
  24.  */
  25.  
  26. class NBClasses.chatsocket extends XMLSocket {
  27.     var _sStartChannel, _sHost, _nPort, _sUsername, _sUserPass, _sAuthPass, sStartChannel;
  28.     var _sServer, iIdleCount;
  29.    
  30.     var onWrite:Function, onJoin:Function, onQuit:Function, onPart:Function,
  31.         onPrivmsg:Function, onPrivmsgPr:Function, onChanPrivmsg:Function, onNameslist:Function, onUserMode:Function,
  32.         onChanMode:Function, onChanModeWParams:Function, on324:Function, onNick:Function, onWhisper:Function,
  33.         on821Chan:Function, on822Chan:Function, on821Pr:Function, on822Pr:Function, on332:Function;
  34.     var onNoticeChanBroadcast:Function, onNoticePrivate:Function, onNotice:Function,
  35.         onNoticeServerMessage:Function, onNoticeServerBroadcast:Function, onKick:Function, on341:Function,
  36.         onInvite:Function, onKnock:Function, onDataIRC:Function, on301:Function, onSetNick:Function,
  37.         onProp:Function, onErrorReplies:Function;
  38.    
  39.     //
  40.     var ClearReconnectTimer:Function, SetReconnectTimer:Function;
  41.    
  42.     //Privates
  43.     private var _bIsConnected:Boolean, _bConnectionRegistered:Boolean = false;
  44.     private var m_serverName:String;
  45.    
  46.     function chatsocket()
  47.     {
  48.         iIdleCount = 0
  49.     }
  50.    
  51.     //** Properties Begin
  52.     function set IsConnected(bStatus:Boolean)
  53.     {
  54.         _bIsConnected = bStatus;
  55.     }
  56.     function get IsConnected()
  57.     {
  58.         return _bIsConnected;
  59.     }
  60.    
  61.     function set Channel(sChannel:String)
  62.     {
  63.         this._sStartChannel = sChannel;
  64.     }
  65.     function get Channel():String
  66.     {
  67.         return this._sStartChannel;
  68.     }
  69.     // End property
  70.    
  71.     function set Host(sHost:String)
  72.     {
  73.         this._sHost = sHost;
  74.     }
  75.     function get Host():String
  76.     {
  77.         return this._sHost;
  78.     }
  79.     // End property
  80.    
  81.     function set Port(nPort:Number)
  82.     {
  83.         this._nPort = nPort;
  84.     }
  85.     function get Port():Number
  86.     {
  87.         return this._nPort;
  88.     }
  89.     // End property
  90.    
  91.     function set UserName(sUsername:String)
  92.     {
  93.         this._sUsername = sUsername;
  94.     }
  95.     function get UserName():String
  96.     {
  97.         return this._sUsername;
  98.     }
  99.     // End property
  100.    
  101.     function set UserPass(sUserPass:String)
  102.     {
  103.         this._sUserPass = sUserPass;
  104.     }
  105.     function get UserPass():String
  106.     {
  107.         return this._sUserPass;
  108.     }
  109.     // End property
  110.    
  111.     function set AuthPass(sAuthPass:String)
  112.     {
  113.         this._sAuthPass = sAuthPass;
  114.     }
  115.     function get AuthPass():String
  116.     {
  117.         return this._sAuthPass;
  118.     }
  119.     // End property
  120.    
  121.     function set ServerName(sSrvName:String)
  122.     {
  123.         m_serverName = sSrvName;
  124.     }
  125.     function get ServerName():String
  126.     {
  127.         return m_serverName;
  128.     }
  129.    
  130.     //** Properties End
  131.    
  132.     //** Socket Events Begin
  133.     function onConnect(success)
  134.     {
  135.         if (success)
  136.         {
  137.             Write("<font color='#006600'>Connected!</font>");
  138.             this.IsConnected = true;
  139.            
  140.             //NICK >Guest
  141.             //USER anon \"anon.com\" \"0.0.0.0\" :anon
  142.             if (_global.gsLoginType == "auto") this.UserName + random(20000);
  143.             else
  144.             {
  145.                 if (this.UserName.substr(0, 1) != ">") this.UserName = ">" + this.UserName;
  146.             }
  147.             onSetNick(this.UserName);
  148.             IRCSend("NICK " + this.UserName);
  149.             IRCSend("USER anon \"anon.com\" \"0.0.0.0\" :anon");
  150.         }
  151.         else
  152.         {
  153.             Write("<font color='#FF0000'>Couldn't connect.</font>");
  154.             SetReconnectTimer();
  155.         }
  156.         // end if
  157.     }
  158.    
  159.     function onData(raw)
  160.     {
  161.         if (raw.length>0)
  162.         {
  163.             iIdleCount = 0;
  164.            
  165.             var sIrcArray = raw.split("\r\n");
  166.             for (var i=0; i<sIrcArray.length; i++)
  167.             {
  168.                 this.parseString(sIrcArray[i]);
  169.             }
  170.         }
  171.         // End if
  172.     }
  173.    
  174.     function onClose()
  175.     {
  176.         Write("<font color='#FF0000'>Connection closed by the server.</font>");
  177.         _bConnectionRegistered = false;
  178.         this.IsConnected = false;
  179.         SetReconnectTimer();
  180.     }
  181.     //** End of Socket Event
  182.    
  183.     function CSocketConnectCallback()
  184.     {
  185.         CSocketConnect(undefined, undefined);
  186.     }
  187.    
  188.     function CSocketConnect(sHost, nPort)
  189.     {
  190.         ClearReconnectTimer();
  191.        
  192.         if (sHost != undefined && nPort != undefined)
  193.         {
  194.             this.connect(sHost, nPort);
  195.             this.Host = sHost;
  196.             this.Port = nPort;
  197.         }
  198.         else
  199.         {
  200.             this.connect(this.Host, this.Port);
  201.         }
  202.         // end if
  203.        
  204.         _bConnectionRegistered = false;
  205.         Write("<font color='#0000CC'>Connecting to " + this.Host + ":" + this.Port + "</font>");
  206.     }
  207.    
  208.     function CSocketReconnect()
  209.     {
  210.         if (this.IsConnected == true)
  211.         {
  212.             close();
  213.             _bConnectionRegistered = false;
  214.             this.IsConnected = false;
  215.         }
  216.         CSocketConnect();
  217.     }
  218.     // End of the function
  219.    
  220.     function parseString(raw)
  221.     {
  222.         if (raw.length > 0)
  223.         {
  224.             var toks = [];
  225.             var ircmsg = (raw.charAt(0) == ":")?raw.substr(1):raw;
  226.            
  227.             //trace incoming
  228.             //Write("received: " + ircmsg);
  229.            
  230.             toks = ircmsg.split(" ");
  231.            
  232.             switch (toks[0].toLowerCase())
  233.             {
  234.             case "error" :
  235.                 handleError(toks.join(" "));
  236.                 return;
  237.                
  238.             case "ping" :
  239.                 PingReply(toks.slice(1));
  240.                 return;
  241.             }
  242.             // End of switch
  243.            
  244.             switch (toks[1].toLowerCase())
  245.             {
  246.             case "001" : //Welcome to the Internet Relay Network
  247.                 ServerName = toks[0];
  248.                 _bConnectionRegistered = true;
  249.                 GotoRoom();
  250.                 break;
  251.            
  252.             case "251" :
  253.                 onNoticeServerMessage(toks.slice(3).join(" ").substr(1));
  254.                 break;
  255.                
  256.             case "265" :
  257.                 onNoticeServerMessage(toks.slice(3).join(" ").substr(1));
  258.                 break;
  259.                
  260.             case "join" :
  261.                 parseJoin(toks[0], toks[2], toks[3]);
  262.                 break;
  263.                
  264.             case "quit" :
  265.                 onQuit(getNick(toks[0]));
  266.                 break;
  267.                
  268.             case "part" :
  269.                 onPart(getNick(toks[0]), toks[2]);
  270.                 break;
  271.                
  272.             case "notice" :
  273.                 if (toks[0] == ServerName)
  274.                 {
  275.                     //Server Message
  276.                     onNoticeServerMessage(toks.slice(2).join(" "));
  277.                 }
  278.                 else if (toks[3].indexOf("%") == 0)
  279.                 {
  280.                     //channel broadcast
  281.                     onNoticeChanBroadcast(getNick(toks[0]), toks[3], strip(toks.slice(4).join(" ")));
  282.                 }
  283.                 else if (toks[2].indexOf("%") < 0)
  284.                 {
  285.                     //server broadcast
  286.                     if (_bConnectionRegistered == true) onNoticeServerBroadcast(getNick(toks[0]), strip(toks.slice(3).join(" ")));
  287.                     else onNoticeServerMessage(toks.slice(2).join(" "));
  288.                 }
  289.                 else if (toks[4].indexOf(":") == 0)
  290.                 {
  291.                     //private notice
  292.                     onNoticePrivate(getNick(toks[0]), toks[2], strip(toks.slice(4).join(" ")));
  293.                 }
  294.                 else
  295.                 {
  296.                     //normal notice
  297.                     onNotice(getNick(toks[0]), toks[2], strip(toks.slice(3).join(" ")));
  298.                 }
  299.                 break;
  300.            
  301.             case "kick" :
  302.                 onKick(getNick(toks[0]), toks[2], toks[3], strip(toks.slice(4).join(" ")));
  303.                 break;
  304.                
  305.             case "privmsg" :
  306.                 if (toks[0].charAt(0) == "%") onChanPrivmsg(toks[0], toks[2], strip(toks.slice(3).join(" ")));
  307.                 else if (toks[3].charAt(0) == ":") onPrivmsg(getNick(toks[0]), toks[2], toks.slice(3).join(" ").substr(1));
  308.                 else onPrivmsgPr(getNick(toks[0]), toks[2], toks[3], toks.slice(4).join(" ").substr(1));
  309.                 break;
  310.                
  311.             case "whisper" :
  312.             //Format> (:)>Test!0092132f753fba195ff8ce4f53704f74c8@masked WHISPER %#Test >Test2 :message
  313.                 onWhisper(getNick(toks[0]), toks[2], toks[3], toks.slice(4).join(" ").slice(1));
  314.                 break;
  315.                
  316.             case "821" : //unaway message
  317.             /*
  318.                 Formats>
  319.                     Personal>   (:)<user> 821 :User unaway
  320.                     Channel>    (:)<user> 821 <chan> :User unaway
  321.             */
  322.            
  323.                 if (toks[2].indexOf("%") == 0) on821Chan(getNick(toks[0]), toks[2], toks.slice(3).join(" ").slice(1));
  324.                 else on821Pr(getNick(toks[0]), toks.slice(2).join(" ").slice(1));
  325.                 break;
  326.                
  327.             case "822" : //away message
  328.             /*
  329.                 Formats>
  330.                     Personal>   (:)<user> 822 :<user message>
  331.                     Channel>    (:)<user> 822 <chan> :<user message>
  332.             */
  333.                 if (toks[2].indexOf("%") == 0) on822Chan(getNick(toks[0]), toks[2], toks.slice(3).join(" ").slice(1));
  334.                 else on822Pr(getNick(toks[0]), toks.slice(2).join(" ").slice(1));
  335.                 break;
  336.                
  337.             case "301":
  338.                 on301(toks[3], toks.slice(4).join(" ").slice(1));
  339.                 break;
  340.                
  341.             case "353" : //names list reply
  342.                 parseNamesList(ircmsg);
  343.                 break;
  344.                
  345.             case "324"  : //channel modes reply
  346.                 parse324(toks[3], toks[4], toks[5], toks);
  347.                 break;
  348.                
  349.             case "433" : //nick already in use error
  350.             //Format> (:)ChatDriveIrcServer.1 433 >Test >Test :Nickname is already in use
  351.                 Write("Nickname <b>" + UserName + "</b> is already in use.");
  352.                 UserName = UserName + random(20000);
  353.                 if (_bConnectionRegistered == false) onSetNick(UserName);
  354.                 IRCSend("NICK " + UserName);
  355.                 GotoRoom();
  356.                 break;
  357.                
  358.             case "nick" :
  359.             //Format> (:)>Test!0092132f753fba195ff8ce4f53704f74c8@masked NICK :>Test10555
  360.                 onNick(getNick(toks[0]), strip(toks[2]));
  361.                 break;
  362.                
  363.             case "authuser" :
  364.                 if (UserPass == "T")
  365.                 {
  366.                     IRCSend("UTICKET " + AuthPass);
  367.                 }
  368.                 else
  369.                 {
  370.                     IRCSend("LOGIN guest " + AuthPass);
  371.                     //IRCSend("NICK " + UserName);
  372.                     //IRCSend("USER anon \"anon.com\" \"0.0.0.0\" :anon");
  373.                 }
  374.                 IRCSend("CLIENTMODE cd1");
  375.                 break;
  376.                
  377.             case "mode" :
  378.                 parseMode(getNick(toks[0]), toks[2], toks[3], toks[4], toks);
  379.                 break;
  380.                
  381.             case "341" : //invite confirmation
  382.                 on341(toks[2], toks[3], toks[4]);
  383.                 break;
  384.                
  385.             case "invite" :
  386.                 onInvite(getNick(toks[0]), toks[2], strip(toks[3]));
  387.                 break;
  388.                
  389.             case "data" :
  390.             /*
  391.                 :<servername> DATA <nickby> <type> :<message>
  392.                 :<servername> DATA <nickby> PID :<nickof> <pid>
  393.             */
  394.                 onDataIRC(toks[2], toks[3], strip(toks.slice(4).join(" ")));
  395.                 break;
  396.                
  397.             case "knock" :
  398.                 onKnock(toks[0], toks[2], strip(toks.slice(3).join(" ")));
  399.                 break;
  400.                
  401.             case "prop" :
  402.                 onProp(getNick(toks[0]), toks[2], toks[3], strip(toks.slice(4).join(" ")));
  403.                 break;
  404.                
  405.             case "332" :
  406.                 on332(toks[3], strip(toks.slice(4).join(" ")));
  407.                 break;
  408.                
  409.             default :
  410.                 if (isNaN(toks[1]) == false) onErrorReplies(toks[1], toks[2], toks[3], strip(toks.slice(4).join(" ")));
  411.                
  412.                 //unhandledCommand(ircmsg);
  413.                 break;
  414.             }
  415.             // End of switch
  416.         }
  417.         // end if
  418.     }
  419.     // End of the function
  420.    
  421.     function getNick(dat)
  422.     {
  423.         return (dat.slice(0, dat.indexOf("!")));
  424.     }
  425.     // End of the function
  426.    
  427.     function getHost(dat)
  428.     {
  429.         var idxHostStart = dat.indexOf("@") + 1;
  430.         return (dat.substr(idxHostStart));
  431.     }
  432.     // End of the function
  433.    
  434.     function getIdentFromNick(dat)
  435.     {
  436.         var idxIdentStart = dat.indexOf("!") + 1;
  437.         var idxIdentEnd_pp1 = dat.indexOf("@");
  438.         return (dat.slice(idxIdentStart, idxIdentEnd_pp1));
  439.     }
  440.     // End of the function
  441.    
  442.     function strip(dat)
  443.     {
  444.         return (dat.charAt(0, 1) == ":") ? dat.substr(1) : dat;
  445.     }
  446.    
  447.     function stripChr(chr:String, str:String):String
  448.     {
  449.         //keep it for later use
  450.         var sTmp:String = "", idx:Number = -1;
  451.        
  452.         return sTmp;
  453.     }
  454.     // End of the function
  455.    
  456.     private function parseJoin(userstr, flags, chan)
  457.     {
  458.         var oUser:Object = {nick:null, ident:null, host:null, ilevel:0, iprofile:0, away:false, awaymsg:"", voice:false, ignore:false};
  459.         var pos1:Number = -1, pos2:Number = -1;
  460.        
  461.         pos1 = userstr.indexOf("!");
  462.         oUser.nick = userstr.substr(0, pos1);
  463.         pos1++;
  464.         pos2 = userstr.indexOf("@", pos1);
  465.         oUser.ident = userstr.substr(pos1, (pos2-pos1));
  466.         pos2++;
  467.         oUser.host = userstr.substr(pos2);
  468.        
  469.         oUser.ilevel = 0;
  470.        
  471.         switch(flags.charAt(0))
  472.         {
  473.             case "A":
  474.                 oUser.away = true;
  475.                 break;
  476.             case "U":
  477.                 oUser.away = false;
  478.                 break;
  479.         }
  480.                    
  481.         switch(flags.substr(1, 2))
  482.         {
  483.             case "UN":
  484.                 oUser.iprofile = _global.NoProfile;
  485.                 break;
  486.             case "UP":
  487.                 oUser.iprofile = _global.NoGenderWPic;
  488.                 break;
  489.             case "FN":
  490.                 oUser.iprofile = _global.Female;
  491.                 break;
  492.             case "MN":
  493.                 oUser.iprofile = _global.Male;
  494.                 break;
  495.             case "FP":
  496.                 oUser.iprofile = _global.FemaleWPic;
  497.                 break;
  498.             case "MP":
  499.                 oUser.iprofile = _global.MaleWPic;
  500.                 break;
  501.         }
  502.        
  503.         switch(flags.charAt(3))
  504.         {
  505.             case "V":
  506.                 oUser.voice = true;
  507.                 break;
  508.             case "N":
  509.                 oUser.voice = false;
  510.                 break;
  511.         }
  512.        
  513.         if (oUser.nick.charAt(0) == "^") oUser.ilevel = _global.IsStaff;
  514.         onJoin(oUser, chan.substr(1)); //strip colon before channel name
  515.     }
  516.     // End of the function
  517.    
  518.     private function parse324(sChan, sModes, sParam, aModes)
  519.     {
  520.         var sNModes:String = "", s_l_Mode:String = undefined, s_k_Mode:String = undefined;
  521.        
  522.         if ((sParam == undefined) || (sParam.length == 0))
  523.         {
  524.             //test these operations for performance
  525.             sModes = sModes.split("l").join("");
  526.             sModes = sModes.split("k").join("");
  527.            
  528.             if (sModes.length > 1) on324(sChan, sModes.substr(1), undefined, undefined);
  529.             else on324(sChan, "", undefined, undefined)
  530.             return;
  531.         }
  532.         else
  533.         {
  534.             for (var i:Number = 0; i<sModes.length; i++)
  535.             {
  536.                 switch (sModes.charAt(i))
  537.                 {
  538.                     case "l":
  539.                         if (aModes[5] != undefined) s_l_Mode = aModes[5];
  540.                         break;
  541.                     case "k":
  542.                         if (aModes[6] != undefined) s_k_Mode = aModes[6];
  543.                         break;
  544.                     default:
  545.                         sNModes += sModes.charAt(i);
  546.                         break;
  547.                 }
  548.             }
  549.            
  550.             if (sNModes.length > 1) on324(sChan, sNModes.substr(1), s_l_Mode, s_k_Mode);
  551.             else on324(sChan, "", s_l_Mode, s_k_Mode);
  552.         }
  553.     }
  554.    
  555.     private function parseMode(sFrom, sChan, sModes, sParam, aModes)
  556.     {
  557.         var bIsChanModeWParams:Boolean = false;
  558.        
  559.         if (sModes == "-k")
  560.         {
  561.             var modeoplist:Array = new Array();
  562.             var oModeParams:Object = {op:null, mode:null, param:null};
  563.            
  564.             oModeParams.op = "-";
  565.             oModeParams.mode = "k";
  566.             modeoplist.push(oModeParams);
  567.            
  568.             onChanModeWParams(sFrom, modeoplist, sChan);
  569.             return;
  570.         }
  571.         else if ((sParam == undefined) || (sParam.length == 0))
  572.         {
  573.             onChanMode(sFrom, sModes, sChan);
  574.             return;
  575.         }
  576.         else
  577.         {
  578.             for (var i:Number = 0; i<sModes.length; i++)
  579.             {
  580.                 if ((sModes.charAt(i) == "l") || (sModes.charAt(i) == "k"))
  581.                 {
  582.                     bIsChanModeWParams = true;
  583.                     break;
  584.                 }
  585.             }
  586.            
  587.             //
  588.             var m:Number = 0, i:Number = 4;
  589.             var bSignAdd:Boolean = true;
  590.             var modeoplist:Array = new Array();
  591.            
  592.             if (bIsChanModeWParams == false)
  593.             {
  594.                 while((i < aModes.length) || (m < sModes.length))
  595.                 {
  596.                     var oModeParams:Object = {op:null, mode:null, param:null};
  597.                    
  598.                     switch(sModes.charAt(m))
  599.                     {
  600.                         case "-":
  601.                             bSignAdd = false;
  602.                             break;
  603.                         case "+":
  604.                             bSignAdd = true;
  605.                             break;
  606.                         default:
  607.                             oModeParams.op      = (bSignAdd == true) ? "+" : "-";
  608.                             oModeParams.mode    = sModes.charAt(m);
  609.                             oModeParams.param   =  aModes[i];
  610.                             modeoplist.push(oModeParams);
  611.                             i++;
  612.                             break;
  613.                     }
  614.                    
  615.                     m++;
  616.                 }
  617.                
  618.                 onUserMode(sFrom, modeoplist, sChan);
  619.             }
  620.             else
  621.             {
  622.                 while((i < aModes.length) || (m < sModes.length))
  623.                 {
  624.                     var oModeParams:Object = {op:null, mode:null, param:null};
  625.                    
  626.                     switch(sModes.charAt(m))
  627.                     {
  628.                         case "-":
  629.                             bSignAdd = false;
  630.                             break;
  631.                         case "+":
  632.                             bSignAdd = true;
  633.                             break;
  634.                         default:
  635.                             oModeParams.op      = (bSignAdd == true) ? "+" : "-";
  636.                             oModeParams.mode    = sModes.charAt(m);
  637.                             oModeParams.param   =  aModes[i];
  638.                             modeoplist.push(oModeParams);
  639.                             i++;
  640.                             break;
  641.                     }
  642.                    
  643.                     m++;
  644.                 }
  645.                
  646.                 onChanModeWParams(sFrom, modeoplist, sChan);
  647.             }
  648.         }
  649.     }
  650.    
  651.     private function parseNotice(sFrom, sTo, sMessage)
  652.     {
  653.         //ToDo:
  654.     }
  655.     // End of the function
  656.    
  657.     private function parsePrivmsg(sFrom, sTo, sMessage)
  658.     {
  659.         if (sMessage.charAt(0) == ":") sMessage = sMessage.substr(1);
  660.         onPrivmsg(sFrom, sTo, sMessage);
  661.     }
  662.     // End of the function
  663.    
  664.     private function parseNamesList(str)
  665.     {
  666.         var ArrayNLpre:Array, ArrayNLpost:Array = new Array();
  667.        
  668.         ArrayNLpre = str.substr(str.indexOf(":", 2)+1).split(" ");
  669.        
  670.         //NB NamesList Protocol Formant: UFPN,'nickname :: [ (U|A)(F|M|U)(P|N)(N|Y),(+|%|@|.|'|^)nickname ]
  671.         for (var i:Number = 0; i < ArrayNLpre.length; i++)
  672.         {
  673.             var oUser:Object = {nick:null, ident:null, host:null, ilevel:0, iprofile:0, away:false, awaymsg:"", voice:false, ignore:false};
  674.            
  675.             if (ArrayNLpre[i].length > 0)
  676.             {
  677.                 switch(ArrayNLpre[i].charAt(0))
  678.                 {
  679.                     case "A":
  680.                         oUser.away = true;
  681.                         break;
  682.                     case "U":
  683.                         oUser.away = false;
  684.                         break;
  685.                 }
  686.                
  687.                 switch(ArrayNLpre[i].substr(1, 2))
  688.                 {
  689.                     case "UN":
  690.                         oUser.iprofile = _global.NoProfile;
  691.                         break;
  692.                     case "UP":
  693.                         oUser.iprofile = _global.NoGenderWPic;
  694.                         break;
  695.                     case "FN":
  696.                         oUser.iprofile = _global.Female;
  697.                         break;
  698.                     case "MN":
  699.                         oUser.iprofile = _global.Male;
  700.                         break;
  701.                     case "FP":
  702.                         oUser.iprofile = _global.FemaleWPic;
  703.                         break;
  704.                     case "MP":
  705.                         oUser.iprofile = _global.MaleWPic;
  706.                         break;
  707.                 }
  708.                
  709.                 switch(ArrayNLpre[i].charAt(3))
  710.                 {
  711.                     case "V":
  712.                         oUser.voice = true;
  713.                         break;
  714.                     case "N":
  715.                         oUser.voice = false;
  716.                         break;
  717.                 }
  718.                
  719.                 switch(ArrayNLpre[i].charAt(5))
  720.                 {
  721.                     case "^":
  722.                         oUser.ilevel = _global.IsStaff;
  723.                         break;
  724.                     case "'":
  725.                         oUser.ilevel = _global.IsSuperOwner;
  726.                         break;
  727.                     case ".":
  728.                         oUser.ilevel = _global.IsOwner;
  729.                         break;
  730.                     case "@":
  731.                         oUser.ilevel = _global.IsHost;
  732.                         break;
  733.                     case "%":
  734.                         oUser.ilevel = _global.IsHelpOp;
  735.                         break;
  736.                     case "+":
  737.                         oUser.voice = true;
  738.                         break;
  739.                     default:
  740.                         oUser.ilevel = 0;
  741.                 }
  742.                
  743.                 oUser.nick = (oUser.ilevel > 0) ? ArrayNLpre[i].substr(6) : ArrayNLpre[i].substr(5);
  744.                 if (oUser.nick.charAt(0) == "^") oUser.ilevel = _global.IsStaff;
  745.                
  746.                 ArrayNLpost.push(oUser);
  747.             }
  748.         }
  749.        
  750.         onNameslist(ArrayNLpost);
  751.        
  752.     }
  753.    
  754.     function GotoRoom()
  755.     {
  756.         if (Channel.length > 0)
  757.         {
  758.             IRCSend("CREATE " + Channel);
  759.         }
  760.         // end if
  761.     }
  762.     // End of the function
  763.    
  764.     function handleError(sError)
  765.     {
  766.         Write("<font color='#FF0000'>Error: " + sError + "</font>");
  767.     }
  768.     // End of the function
  769.    
  770.     function unhandledCommand(sCmd)
  771.     {
  772.         Write("Unhandled Command:" + sCmd);
  773.     }
  774.    
  775.     function handleError2(sError)
  776.     {
  777.         Write(sError);
  778.     }
  779.    
  780.     function PingReply(sData)
  781.     {
  782.         IRCSend("PONG " + sData.toString());
  783.     }
  784.     // End of the function
  785.    
  786.     function sendToChan(chan, msg)
  787.     {
  788.         IRCSend("PRIVMSG " + chan + " :" + msg);
  789.     }
  790.     // End of the function
  791.    
  792.     function IRCSend(sMsg)
  793.     {
  794.         send(sMsg + "\r\n");
  795.     }
  796.    
  797.     function Write(str)
  798.     {
  799.         onWrite(str);
  800.     }
  801. }
  802. // End of Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement