예제 #1
0
        public static WhoInfo Parse(IrcMessageData data)
        {
            WhoInfo whoInfo = new WhoInfo();
            // :fu-berlin.de 352 meebey_ * ~meebey e176002059.adsl.alicedsl.de fu-berlin.de meebey_ H :0 Mirco Bauer..
            whoInfo.f_Channel  = data.RawMessageArray[3];
            whoInfo.f_Ident    = data.RawMessageArray[4];
            whoInfo.f_Host     = data.RawMessageArray[5];
            whoInfo.f_Server   = data.RawMessageArray[6];
            whoInfo.f_Nick     = data.RawMessageArray[7];
            // skip hop count
            whoInfo.f_Realname = String.Join(" ", data.MessageArray, 1, data.MessageArray.Length - 1);
            
            int    hopcount = 0;
            string hopcountStr = data.MessageArray[0];
            try {
                hopcount = int.Parse(hopcountStr);
            } catch (FormatException ex) {
#if LOG4NET
                Logger.MessageParser.Warn("Parse(): couldn't parse (as int): '" + hopcountStr + "'", ex);
#endif
            }

            string usermode = data.RawMessageArray[8];
            bool op = false;
            bool voice = false;
            bool ircop = false;
            bool away = false;
            bool registered = false;
            int usermodelength = usermode.Length;
            for (int i = 0; i < usermodelength; i++) {
                switch (usermode[i]) {
                    case 'H':
                        away = false;
                    break;
                    case 'G':
                        away = true;
                    break;
                    case '@':
                        op = true;
                    break;
                    case '+':
                        voice = true;
                    break;
                    case '*':
                        ircop = true;
                    break;
                    case 'r':
                        registered = true;
                    break;
                }
            }
            whoInfo.f_IsAway = away;
            whoInfo.f_IsOp = op;
            whoInfo.f_IsVoice = voice;
            whoInfo.f_IsIrcOp = ircop;

            whoInfo.f_IsRegistered = registered;
            
            return whoInfo;
        }
예제 #2
0
        public static WhoInfo Parse(IrcMessageData data)
        {
            WhoInfo whoInfo = new WhoInfo();

            whoInfo.f_Channel  = data.RawMessageArray[3];
            whoInfo.f_Ident    = data.RawMessageArray[4];
            whoInfo.f_Host     = data.RawMessageArray[5];
            whoInfo.f_Server   = data.RawMessageArray[6];
            whoInfo.f_Nick     = data.RawMessageArray[7];
            whoInfo.f_Realname = string.Join(" ", data.MessageArray, 1, data.MessageArray.Length - 1);
            string message = data.MessageArray[0];

            try
            {
                int.Parse(message);
            }
            catch (FormatException ex)
            {
            }
            string rawMessage = data.RawMessageArray[8];
            bool   flag1      = false;
            bool   flag2      = false;
            bool   flag3      = false;
            bool   flag4      = false;
            int    length     = rawMessage.Length;

            for (int index = 0; index < length; ++index)
            {
                switch (rawMessage[index])
                {
                case '*':
                    flag3 = true;
                    break;

                case '+':
                    flag2 = true;
                    break;

                case '@':
                    flag1 = true;
                    break;

                case 'G':
                    flag4 = true;
                    break;

                case 'H':
                    flag4 = false;
                    break;
                }
            }
            whoInfo.f_IsAway  = flag4;
            whoInfo.f_IsOp    = flag1;
            whoInfo.f_IsVoice = flag2;
            whoInfo.f_IsIrcOp = flag3;
            return(whoInfo);
        }
예제 #3
0
 internal WhoEventArgs(IrcMessageData data, WhoInfo whoInfo)
     : base(data)
 {
     f_WhoInfo = whoInfo;
 }
예제 #4
0
 internal WhoEventArgs(IrcMessageData data, WhoInfo whoInfo) : base(data)
 {
     f_WhoInfo = whoInfo;
 }
예제 #5
0
        public static WhoInfo Parse(IrcMessageData data)
        {
            var whoInfo = new WhoInfo
            {
                // :fu-berlin.de 352 meebey_ * ~meebey e176002059.adsl.alicedsl.de fu-berlin.de meebey_ H :0 Mirco Bauer..
                Channel = data.RawMessageArray[3],
                Ident   = data.RawMessageArray[4],
                Host    = data.RawMessageArray[5],
                Server  = data.RawMessageArray[6],
                Nick    = data.RawMessageArray[7]
            };

            // HACK: realname field can be empty on bugged IRCds like InspIRCd-2.0
            // :topiary.voxanon.net 352 Mirco #anonplusradio CpGc igot.avhost Voxanon CpGc H
            if (data.MessageArray == null || data.MessageArray.Length < 2)
            {
                whoInfo.Realname = "";
            }
            else
            {
                string hopcountStr = data.MessageArray[0];
                if (Int32.TryParse(hopcountStr, out int hopcount))
                {
                    whoInfo.HopCount = hopcount;
                }
                else
                {
#if LOG4NET
                    Logger.MessageParser.Warn("Parse(): couldn't parse hopcount (as int): '" + hopcountStr + "'");
#endif
                }
                // skip hop count
                whoInfo.Realname = String.Join(" ", data.MessageArray, 1, data.MessageArray.Length - 1);
            }

            string usermode       = data.RawMessageArray[8];
            bool   owner          = false;
            bool   chanadmin      = false;
            bool   op             = false;
            bool   halfop         = false;
            bool   voice          = false;
            bool   ircop          = false;
            bool   away           = false;
            bool   registered     = false;
            int    usermodelength = usermode.Length;
            for (int i = 0; i < usermodelength; i++)
            {
                switch (usermode[i])
                {
                case 'H':
                    away = false;
                    break;

                case 'G':
                    away = true;
                    break;

                case '~':
                    owner = true;
                    break;

                case '&':
                    chanadmin = true;
                    break;

                case '@':
                    op = true;
                    break;

                case '%':
                    halfop = true;
                    break;

                case '+':
                    voice = true;
                    break;

                case '*':
                    ircop = true;
                    break;

                case 'r':
                    registered = true;
                    break;
                }
            }
            whoInfo.IsAway         = away;
            whoInfo.IsOwner        = owner;
            whoInfo.IsChannelAdmin = chanadmin;
            whoInfo.IsOp           = op;
            whoInfo.IsHalfop       = halfop;
            whoInfo.IsVoice        = voice;
            whoInfo.IsIrcOp        = ircop;

            whoInfo.IsRegistered = registered;

            return(whoInfo);
        }
예제 #6
0
        public static WhoInfo Parse(IrcMessageData data)
        {
            WhoInfo whoInfo = new WhoInfo();
            // :fu-berlin.de 352 meebey_ * ~meebey e176002059.adsl.alicedsl.de fu-berlin.de meebey_ H :0 Mirco Bauer..
            whoInfo.f_Channel  = data.RawMessageArray[3];
            whoInfo.f_Ident    = data.RawMessageArray[4];
            whoInfo.f_Host     = data.RawMessageArray[5];
            whoInfo.f_Server   = data.RawMessageArray[6];
            whoInfo.f_Nick     = data.RawMessageArray[7];
            // skip hop count
            whoInfo.f_Realname = String.Join(" ", data.MessageArray, 1, data.MessageArray.Length - 1);
            
            int    hopcount = 0;
            string hopcountStr = data.MessageArray[0];
            try {
                hopcount = int.Parse(hopcountStr);
            } catch (FormatException ex) {
#if LOG4NET
                Logger.MessageParser.Warn("Parse(): couldn't parse (as int): '" + hopcountStr + "'", ex);
#endif
            }

            string usermode = data.RawMessageArray[8];
            bool op = false;
            bool voice = false;
            bool ircop = false;
            bool away = false;
            int usermodelength = usermode.Length;
            for (int i = 0; i < usermodelength; i++) {
                switch (usermode[i]) {
                    case 'H':
                        away = false;
                    break;
                    case 'G':
                        away = true;
                    break;
                    case '@':
                        op = true;
                    break;
                    case '+':
                        voice = true;
                    break;
                    case '*':
                        ircop = true;
                    break;
                }
            }
            whoInfo.f_IsAway = away;
            whoInfo.f_IsOp = op;
            whoInfo.f_IsVoice = voice;
            whoInfo.f_IsIrcOp = ircop;
            
            return whoInfo;
        }
예제 #7
0
파일: WhoInfo.cs 프로젝트: groma84/IrcBots
        public static WhoInfo Parse(IrcMessageData data)
        {
            WhoInfo whoInfo = new WhoInfo();
            // :fu-berlin.de 352 meebey_ * ~meebey e176002059.adsl.alicedsl.de fu-berlin.de meebey_ H :0 Mirco Bauer..
            whoInfo.f_Channel  = data.RawMessageArray[3];
            whoInfo.f_Ident    = data.RawMessageArray[4];
            whoInfo.f_Host     = data.RawMessageArray[5];
            whoInfo.f_Server   = data.RawMessageArray[6];
            whoInfo.f_Nick     = data.RawMessageArray[7];

            // HACK: realname field can be empty on bugged IRCds like InspIRCd-2.0
            // :topiary.voxanon.net 352 Mirco #anonplusradio CpGc igot.avhost Voxanon CpGc H
            if (data.MessageArray == null || data.MessageArray.Length < 2) {
                whoInfo.f_Realname = String.Empty;
            } else {
                int hopcount = 0;
                var hopcountStr = data.MessageArray[0];
                if (Int32.TryParse(hopcountStr, out hopcount)) {
                    whoInfo.f_HopCount = hopcount;
                } else {
            #if LOG4NET
                    Logger.MessageParser.Warn("Parse(): couldn't parse hopcount (as int): '" + hopcountStr + "'");
            #endif
                }
                // skip hop count
                whoInfo.f_Realname = String.Join(" ", data.MessageArray, 1, data.MessageArray.Length - 1);
            }

            string usermode = data.RawMessageArray[8];
            bool owner = false;
            bool chanadmin = false;
            bool op = false;
            bool halfop = false;
            bool voice = false;
            bool ircop = false;
            bool away = false;
            bool registered = false;
            int usermodelength = usermode.Length;
            for (int i = 0; i < usermodelength; i++) {
                switch (usermode[i]) {
                    case 'H':
                        away = false;
                    break;
                    case 'G':
                        away = true;
                    break;
                    case '~':
                        owner = true;
                    break;
                    case '&':
                        chanadmin = true;
                    break;
                    case '@':
                        op = true;
                    break;
                    case '%':
                        halfop = true;
                    break;
                    case '+':
                        voice = true;
                    break;
                    case '*':
                        ircop = true;
                    break;
                    case 'r':
                        registered = true;
                    break;
                }
            }
            whoInfo.f_IsAway = away;
            whoInfo.f_IsOwner = owner;
            whoInfo.f_IsChannelAdmin = chanadmin;
            whoInfo.f_IsOp = op;
            whoInfo.f_IsHalfop = halfop;
            whoInfo.f_IsVoice = voice;
            whoInfo.f_IsIrcOp = ircop;

            whoInfo.f_IsRegistered = registered;

            return whoInfo;
        }