fCraft.IRC.GetMessageType C# (CSharp) Method

GetMessageType() private static method

private static GetMessageType ( [ rawline, [ actualBotNick ) : IRCMessageType
rawline [
actualBotNick [
return IRCMessageType
        private static IRCMessageType GetMessageType( [NotNull] string rawline, [NotNull] string actualBotNick ) {
            if ( rawline == null )
                throw new ArgumentNullException( "rawline" );
            if ( actualBotNick == null )
                throw new ArgumentNullException( "actualBotNick" );

            Match found = ReplyCodeRegex.Match( rawline );
            if ( found.Success ) {
                string code = found.Groups[1].Value;
                IRCReplyCode replycode = ( IRCReplyCode )int.Parse( code );

                // check if this replycode is known in the RFC
                if ( Array.IndexOf( ReplyCodes, replycode ) == -1 ) {
                    return IRCMessageType.Unknown;
                }

                switch ( replycode ) {
                    case IRCReplyCode.Welcome:
                    case IRCReplyCode.YourHost:
                    case IRCReplyCode.Created:
                    case IRCReplyCode.MyInfo:
                    case IRCReplyCode.Bounce:
                        return IRCMessageType.Login;
                    case IRCReplyCode.StatsConn:
                    case IRCReplyCode.LocalUsers:
                    case IRCReplyCode.GlobalUsers:
                    case IRCReplyCode.LuserClient:
                    case IRCReplyCode.LuserOp:
                    case IRCReplyCode.LuserUnknown:
                    case IRCReplyCode.LuserMe:
                    case IRCReplyCode.LuserChannels:
                        return IRCMessageType.Info;
                    case IRCReplyCode.MotdStart:
                    case IRCReplyCode.Motd:
                    case IRCReplyCode.EndOfMotd:
                        return IRCMessageType.Motd;
                    case IRCReplyCode.NamesReply:
                    case IRCReplyCode.EndOfNames:
                        return IRCMessageType.Name;
                    case IRCReplyCode.WhoReply:
                    case IRCReplyCode.EndOfWho:
                        return IRCMessageType.Who;
                    case IRCReplyCode.ListStart:
                    case IRCReplyCode.List:
                    case IRCReplyCode.ListEnd:
                        return IRCMessageType.List;
                    case IRCReplyCode.BanList:
                    case IRCReplyCode.EndOfBanList:
                        return IRCMessageType.BanList;
                    case IRCReplyCode.Topic:
                    case IRCReplyCode.TopicSetBy:
                    case IRCReplyCode.NoTopic:
                        return IRCMessageType.Topic;
                    case IRCReplyCode.WhoIsUser:
                    case IRCReplyCode.WhoIsServer:
                    case IRCReplyCode.WhoIsOperator:
                    case IRCReplyCode.WhoIsIdle:
                    case IRCReplyCode.WhoIsChannels:
                    case IRCReplyCode.EndOfWhoIs:
                        return IRCMessageType.WhoIs;
                    case IRCReplyCode.WhoWasUser:
                    case IRCReplyCode.EndOfWhoWas:
                        return IRCMessageType.WhoWas;
                    case IRCReplyCode.UserModeIs:
                        return IRCMessageType.UserMode;
                    case IRCReplyCode.ChannelModeIs:
                        return IRCMessageType.ChannelMode;
                    default:
                        if ( ( ( int )replycode >= 400 ) &&
                            ( ( int )replycode <= 599 ) ) {
                            return IRCMessageType.ErrorMessage;
                        } else {
                            return IRCMessageType.Unknown;
                        }
                }
            }

            found = PingRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.Ping;
            }

            found = ErrorRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.Error;
            }

            found = ActionRegex.Match( rawline );
            if ( found.Success ) {
                switch ( found.Groups[1].Value ) {
                    case "#":
                    case "!":
                    case "&":
                    case "+":
                        return IRCMessageType.ChannelAction;
                    default:
                        return IRCMessageType.QueryAction;
                }
            }

            found = CtcpRequestRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.CtcpRequest;
            }

            found = MessageRegex.Match( rawline );
            if ( found.Success ) {
                switch ( found.Groups[1].Value ) {
                    case "#":
                    case "!":
                    case "&":
                    case "+":
                        return IRCMessageType.ChannelMessage;
                    default:
                        return IRCMessageType.QueryMessage;
                }
            }

            found = CtcpReplyRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.CtcpReply;
            }

            found = NoticeRegex.Match( rawline );
            if ( found.Success ) {
                switch ( found.Groups[1].Value ) {
                    case "#":
                    case "!":
                    case "&":
                    case "+":
                        return IRCMessageType.ChannelNotice;
                    default:
                        return IRCMessageType.QueryNotice;
                }
            }

            found = InviteRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.Invite;
            }

            found = JoinRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.Join;
            }

            found = TopicRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.TopicChange;
            }

            found = NickRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.NickChange;
            }

            found = KickRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.Kick;
            }

            found = PartRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.Part;
            }

            found = ModeRegex.Match( rawline );
            if ( found.Success ) {
                if ( found.Groups[1].Value == actualBotNick ) {
                    return IRCMessageType.UserModeChange;
                } else {
                    return IRCMessageType.ChannelModeChange;
                }
            }

            found = QuitRegex.Match( rawline );
            if ( found.Success ) {
                return IRCMessageType.Quit;
            }

            found = KillRegex.Match( rawline );
            return found.Success ? IRCMessageType.Kill : IRCMessageType.Unknown;
        }