Esempio n. 1
0
        private void InvokeEvent(LazyNotification lazyNotification)
        {
            var ntf = lazyNotification.Notifications;

            switch (lazyNotification.NotifyType)
            {
            case NotificationType.ChannelChanged: {
                var ntfc = (ChannelChanged[])ntf;
                ProcessChannelChanged(ntfc);
                OnChannelChanged?.Invoke(this, ntfc);
                var ev   = OnEachChannelChanged;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelChanged(that);
                }
                break;
            }

            case NotificationType.ChannelCreated: {
                var ntfc = (ChannelCreated[])ntf;
                ProcessChannelCreated(ntfc);
                OnChannelCreated?.Invoke(this, ntfc);
                var ev   = OnEachChannelCreated;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelCreated(that);
                    book?.UpdateChannelCreated(that);
                }
                break;
            }

            case NotificationType.ChannelDeleted: {
                var ntfc = (ChannelDeleted[])ntf;
                ProcessChannelDeleted(ntfc);
                OnChannelDeleted?.Invoke(this, ntfc);
                var ev   = OnEachChannelDeleted;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelDeleted(that);
                    book?.UpdateChannelDeleted(that);
                }
                break;
            }

            case NotificationType.ChannelEdited: {
                var ntfc = (ChannelEdited[])ntf;
                ProcessChannelEdited(ntfc);
                OnChannelEdited?.Invoke(this, ntfc);
                var ev   = OnEachChannelEdited;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelEdited(that);
                    book?.UpdateChannelEdited(that);
                }
                break;
            }

            case NotificationType.ChannelGroupList: {
                var ntfc = (ChannelGroupList[])ntf;
                ProcessChannelGroupList(ntfc);
                OnChannelGroupList?.Invoke(this, ntfc);
                var ev   = OnEachChannelGroupList;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelGroupList(that);
                }
                break;
            }

            case NotificationType.ChannelList: {
                var ntfc = (ChannelList[])ntf;
                ProcessChannelList(ntfc);
                OnChannelList?.Invoke(this, ntfc);
                var ev   = OnEachChannelList;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelList(that);
                    book?.UpdateChannelList(that);
                }
                break;
            }

            case NotificationType.ChannelListFinished: {
                var ntfc = (ChannelListFinished[])ntf;
                ProcessChannelListFinished(ntfc);
                OnChannelListFinished?.Invoke(this, ntfc);
                var ev   = OnEachChannelListFinished;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelListFinished(that);
                }
                break;
            }

            case NotificationType.ChannelMoved: {
                var ntfc = (ChannelMoved[])ntf;
                ProcessChannelMoved(ntfc);
                OnChannelMoved?.Invoke(this, ntfc);
                var ev   = OnEachChannelMoved;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelMoved(that);
                    book?.UpdateChannelMoved(that);
                }
                break;
            }

            case NotificationType.ChannelPasswordChanged: {
                var ntfc = (ChannelPasswordChanged[])ntf;
                ProcessChannelPasswordChanged(ntfc);
                OnChannelPasswordChanged?.Invoke(this, ntfc);
                var ev   = OnEachChannelPasswordChanged;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelPasswordChanged(that);
                }
                break;
            }

            case NotificationType.ChannelSubscribed: {
                var ntfc = (ChannelSubscribed[])ntf;
                ProcessChannelSubscribed(ntfc);
                OnChannelSubscribed?.Invoke(this, ntfc);
                var ev   = OnEachChannelSubscribed;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelSubscribed(that);
                }
                break;
            }

            case NotificationType.ChannelUnsubscribed: {
                var ntfc = (ChannelUnsubscribed[])ntf;
                ProcessChannelUnsubscribed(ntfc);
                OnChannelUnsubscribed?.Invoke(this, ntfc);
                var ev   = OnEachChannelUnsubscribed;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachChannelUnsubscribed(that);
                }
                break;
            }

            case NotificationType.ClientChannelGroupChanged: {
                var ntfc = (ClientChannelGroupChanged[])ntf;
                ProcessClientChannelGroupChanged(ntfc);
                OnClientChannelGroupChanged?.Invoke(this, ntfc);
                var ev   = OnEachClientChannelGroupChanged;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientChannelGroupChanged(that);
                    book?.UpdateClientChannelGroupChanged(that);
                }
                break;
            }

            case NotificationType.ClientChatComposing: {
                var ntfc = (ClientChatComposing[])ntf;
                ProcessClientChatComposing(ntfc);
                OnClientChatComposing?.Invoke(this, ntfc);
                var ev   = OnEachClientChatComposing;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientChatComposing(that);
                }
                break;
            }

            case NotificationType.ClientDbIdFromUid: {
                var ntfc = (ClientDbIdFromUid[])ntf;
                ProcessClientDbIdFromUid(ntfc);
                OnClientDbIdFromUid?.Invoke(this, ntfc);
                var ev   = OnEachClientDbIdFromUid;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientDbIdFromUid(that);
                }
                break;
            }

            case NotificationType.ClientEnterView: {
                var ntfc = (ClientEnterView[])ntf;
                ProcessClientEnterView(ntfc);
                OnClientEnterView?.Invoke(this, ntfc);
                var ev   = OnEachClientEnterView;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientEnterView(that);
                    book?.UpdateClientEnterView(that);
                }
                break;
            }

            case NotificationType.ClientIds: {
                var ntfc = (ClientIds[])ntf;
                ProcessClientIds(ntfc);
                OnClientIds?.Invoke(this, ntfc);
                var ev   = OnEachClientIds;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientIds(that);
                }
                break;
            }

            case NotificationType.ClientLeftView: {
                var ntfc = (ClientLeftView[])ntf;
                ProcessClientLeftView(ntfc);
                OnClientLeftView?.Invoke(this, ntfc);
                var ev   = OnEachClientLeftView;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientLeftView(that);
                    book?.UpdateClientLeftView(that);
                }
                break;
            }

            case NotificationType.ClientMoved: {
                var ntfc = (ClientMoved[])ntf;
                ProcessClientMoved(ntfc);
                OnClientMoved?.Invoke(this, ntfc);
                var ev   = OnEachClientMoved;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientMoved(that);
                    book?.UpdateClientMoved(that);
                }
                break;
            }

            case NotificationType.ClientNeededPermissions: {
                var ntfc = (ClientNeededPermissions[])ntf;
                ProcessClientNeededPermissions(ntfc);
                OnClientNeededPermissions?.Invoke(this, ntfc);
                var ev   = OnEachClientNeededPermissions;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientNeededPermissions(that);
                }
                break;
            }

            case NotificationType.ClientPoke: {
                var ntfc = (ClientPoke[])ntf;
                ProcessClientPoke(ntfc);
                OnClientPoke?.Invoke(this, ntfc);
                var ev   = OnEachClientPoke;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientPoke(that);
                }
                break;
            }

            case NotificationType.ClientServerGroup: {
                var ntfc = (ClientServerGroup[])ntf;
                ProcessClientServerGroup(ntfc);
                OnClientServerGroup?.Invoke(this, ntfc);
                var ev   = OnEachClientServerGroup;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientServerGroup(that);
                }
                break;
            }

            case NotificationType.ClientServerGroupAdded: {
                var ntfc = (ClientServerGroupAdded[])ntf;
                ProcessClientServerGroupAdded(ntfc);
                OnClientServerGroupAdded?.Invoke(this, ntfc);
                var ev   = OnEachClientServerGroupAdded;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachClientServerGroupAdded(that);
                    book?.UpdateClientServerGroupAdded(that);
                }
                break;
            }

            case NotificationType.CommandError: {
                var ntfc = (CommandError[])ntf;
                ProcessCommandError(ntfc);
                OnCommandError?.Invoke(this, ntfc);
                var ev   = OnEachCommandError;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachCommandError(that);
                }
                break;
            }

            case NotificationType.ConnectionInfo: {
                var ntfc = (ConnectionInfo[])ntf;
                ProcessConnectionInfo(ntfc);
                OnConnectionInfo?.Invoke(this, ntfc);
                var ev   = OnEachConnectionInfo;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachConnectionInfo(that);
                    book?.UpdateConnectionInfo(that);
                }
                break;
            }

            case NotificationType.ConnectionInfoRequest: {
                var ntfc = (ConnectionInfoRequest[])ntf;
                ProcessConnectionInfoRequest(ntfc);
                OnConnectionInfoRequest?.Invoke(this, ntfc);
                var ev   = OnEachConnectionInfoRequest;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachConnectionInfoRequest(that);
                }
                break;
            }

            case NotificationType.FileDownload: {
                var ntfc = (FileDownload[])ntf;
                ProcessFileDownload(ntfc);
                OnFileDownload?.Invoke(this, ntfc);
                var ev   = OnEachFileDownload;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachFileDownload(that);
                }
                break;
            }

            case NotificationType.FileInfoTs: {
                var ntfc = (FileInfoTs[])ntf;
                ProcessFileInfoTs(ntfc);
                OnFileInfoTs?.Invoke(this, ntfc);
                var ev   = OnEachFileInfoTs;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachFileInfoTs(that);
                }
                break;
            }

            case NotificationType.FileList: {
                var ntfc = (FileList[])ntf;
                ProcessFileList(ntfc);
                OnFileList?.Invoke(this, ntfc);
                var ev   = OnEachFileList;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachFileList(that);
                }
                break;
            }

            case NotificationType.FileListFinished: {
                var ntfc = (FileListFinished[])ntf;
                ProcessFileListFinished(ntfc);
                OnFileListFinished?.Invoke(this, ntfc);
                var ev   = OnEachFileListFinished;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachFileListFinished(that);
                }
                break;
            }

            case NotificationType.FileTransfer: {
                var ntfc = (FileTransfer[])ntf;
                ProcessFileTransfer(ntfc);
                OnFileTransfer?.Invoke(this, ntfc);
                var ev   = OnEachFileTransfer;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachFileTransfer(that);
                }
                break;
            }

            case NotificationType.FileTransferStatus: {
                var ntfc = (FileTransferStatus[])ntf;
                ProcessFileTransferStatus(ntfc);
                OnFileTransferStatus?.Invoke(this, ntfc);
                var ev   = OnEachFileTransferStatus;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachFileTransferStatus(that);
                }
                break;
            }

            case NotificationType.FileUpload: {
                var ntfc = (FileUpload[])ntf;
                ProcessFileUpload(ntfc);
                OnFileUpload?.Invoke(this, ntfc);
                var ev   = OnEachFileUpload;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachFileUpload(that);
                }
                break;
            }

            case NotificationType.InitIvExpand: {
                var ntfc = (InitIvExpand[])ntf;
                ProcessInitIvExpand(ntfc);
                OnInitIvExpand?.Invoke(this, ntfc);
                var ev   = OnEachInitIvExpand;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachInitIvExpand(that);
                }
                break;
            }

            case NotificationType.InitIvExpand2: {
                var ntfc = (InitIvExpand2[])ntf;
                ProcessInitIvExpand2(ntfc);
                OnInitIvExpand2?.Invoke(this, ntfc);
                var ev   = OnEachInitIvExpand2;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachInitIvExpand2(that);
                }
                break;
            }

            case NotificationType.InitServer: {
                var ntfc = (InitServer[])ntf;
                ProcessInitServer(ntfc);
                OnInitServer?.Invoke(this, ntfc);
                var ev   = OnEachInitServer;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachInitServer(that);
                    book?.UpdateInitServer(that);
                }
                break;
            }

            case NotificationType.PluginCommand: {
                var ntfc = (PluginCommand[])ntf;
                ProcessPluginCommand(ntfc);
                OnPluginCommand?.Invoke(this, ntfc);
                var ev   = OnEachPluginCommand;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachPluginCommand(that);
                }
                break;
            }

            case NotificationType.ServerEdited: {
                var ntfc = (ServerEdited[])ntf;
                ProcessServerEdited(ntfc);
                OnServerEdited?.Invoke(this, ntfc);
                var ev   = OnEachServerEdited;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachServerEdited(that);
                    book?.UpdateServerEdited(that);
                }
                break;
            }

            case NotificationType.ServerGroupList: {
                var ntfc = (ServerGroupList[])ntf;
                ProcessServerGroupList(ntfc);
                OnServerGroupList?.Invoke(this, ntfc);
                var ev   = OnEachServerGroupList;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachServerGroupList(that);
                    book?.UpdateServerGroupList(that);
                }
                break;
            }

            case NotificationType.TextMessage: {
                var ntfc = (TextMessage[])ntf;
                ProcessTextMessage(ntfc);
                OnTextMessage?.Invoke(this, ntfc);
                var ev   = OnEachTextMessage;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachTextMessage(that);
                }
                break;
            }

            case NotificationType.TokenUsed: {
                var ntfc = (TokenUsed[])ntf;
                ProcessTokenUsed(ntfc);
                OnTokenUsed?.Invoke(this, ntfc);
                var ev   = OnEachTokenUsed;
                var book = Book;
                foreach (var that in ntfc)
                {
                    ev?.Invoke(this, that);
                    ProcessEachTokenUsed(that);
                }
                break;
            }

            case NotificationType.Unknown:
            default:
                throw Util.UnhandledDefault(lazyNotification.NotifyType);
            }
        }
Esempio n. 2
0
        public void ParseReply(string[] tokens)
        {
            ReplyCode code = (ReplyCode)int.Parse(tokens[1], CultureInfo.InvariantCulture);

            tokens[3] = RemoveLeadingColon(tokens[3]);
            switch (code)
            {
            //Messages sent upon successful registration
            case ReplyCode.RPL_WELCOME:
            case ReplyCode.RPL_YOURESERVICE:
                OnRegistered.Fire(this, new EventArgs());
                break;

            case ReplyCode.RPL_MOTDSTART:
            case ReplyCode.RPL_MOTD:
                OnMotd?.Invoke(CondenseStrings(tokens, 3), false);
                break;

            case ReplyCode.RPL_ENDOFMOTD:
                OnMotd?.Invoke(CondenseStrings(tokens, 3), true);
                break;

            case ReplyCode.RPL_ISON:
                OnIson?.Invoke(tokens[3]);
                break;

            case ReplyCode.RPL_NAMREPLY:
                ProcessNamesReply(tokens, false);
                break;

            case ReplyCode.RPL_ENDOFNAMES:
                ProcessNamesReply(tokens, true);
                break;

            case ReplyCode.RPL_LIST:
                tokens[5] = RemoveLeadingColon(tokens[5]);
                OnList?.Invoke(
                    tokens[3],
                    int.Parse(tokens[4], CultureInfo.InvariantCulture),
                    CondenseStrings(tokens, 5),
                    false);
                break;

            case ReplyCode.RPL_LISTEND:
                OnList?.Invoke("", 0, "", true);
                break;

            case ReplyCode.ERR_NICKNAMEINUSE:
            case ReplyCode.ERR_NICKCOLLISION:
                tokens[4] = RemoveLeadingColon(tokens[4]);
                OnNickError.Fire(this, new NickErrorEventArgs(tokens[3], CondenseStrings(tokens, 4)));
                //Trace.WriteLine("Nick collision", "IRC");
                break;

            case ReplyCode.RPL_NOTOPIC:
                OnError.Fire(this, new ErrorMessageEventArgs(code, CondenseStrings(tokens, 3)));
                break;

            case ReplyCode.RPL_TOPIC:
                tokens[4] = RemoveLeadingColon(tokens[4]);
                OnRecieveTopic?.Invoke(tokens[3], CondenseStrings(tokens, 4));
                break;

            case ReplyCode.RPL_INVITING:
                OnInviteSent.Fire(this, new InviteEventArgs(tokens[3], tokens[4]));
                break;

            case ReplyCode.RPL_AWAY:
                OnAway.Fire(this, new AwayEventArgs(tokens[3], RemoveLeadingColon(CondenseStrings(tokens, 4))));
                break;

            case ReplyCode.RPL_WHOREPLY:
                User user = new User(tokens[7], tokens[4], tokens[5]);
                OnWho?.Invoke(
                    user,
                    tokens[3],
                    tokens[6],
                    tokens[8],
                    int.Parse(RemoveLeadingColon(tokens[9]), CultureInfo.InvariantCulture),
                    tokens[10],
                    false);
                break;

            case ReplyCode.RPL_ENDOFWHO:
                OnWho?.Invoke(User.Empty, "", "", "", 0, "", true);
                break;

            case ReplyCode.RPL_WHOISUSER:
                User      whoUser   = new User(tokens[3], tokens[4], tokens[5]);
                WhoisInfo whoisInfo = LookupInfo(whoUser.Nick);
                whoisInfo.user     = whoUser;
                tokens[7]          = RemoveLeadingColon(tokens[7]);
                whoisInfo.realName = CondenseStrings(tokens, 7);
                break;

            case ReplyCode.RPL_WHOISCHANNELS:
                WhoisInfo whoisChannelInfo = LookupInfo(tokens[3]);
                tokens[4] = RemoveLeadingColon(tokens[4]);
                int      numberOfChannels = tokens.Length - 4;
                string[] channels         = new String[numberOfChannels];
                Array.Copy(tokens, 4, channels, 0, numberOfChannels);
                whoisChannelInfo.SetChannels(channels);
                break;

            case ReplyCode.RPL_WHOISSERVER:
                WhoisInfo whoisServerInfo = LookupInfo(tokens[3]);
                whoisServerInfo.ircServer = tokens[4];
                tokens[5] = RemoveLeadingColon(tokens[5]);
                whoisServerInfo.serverDescription = CondenseStrings(tokens, 5);
                break;

            case ReplyCode.RPL_WHOISOPERATOR:
                WhoisInfo whoisOpInfo = LookupInfo(tokens[3]);
                whoisOpInfo.isOperator = true;
                break;

            case ReplyCode.RPL_WHOISIDLE:
                WhoisInfo whoisIdleInfo = LookupInfo(tokens[3]);
                whoisIdleInfo.idleTime = long.Parse(tokens[5], CultureInfo.InvariantCulture);
                break;

            case ReplyCode.RPL_ENDOFWHOIS:
                string    nick         = tokens[3];
                WhoisInfo whoisEndInfo = LookupInfo(nick);
                OnWhois?.Invoke(whoisEndInfo);
                whoisInfos.Remove(nick);
                break;

            case ReplyCode.RPL_WHOWASUSER:
                User whoWasUser = new User(tokens[3], tokens[4], tokens[5]);
                tokens[7] = RemoveLeadingColon(tokens[7]);
                OnWhowas?.Invoke(whoWasUser, CondenseStrings(tokens, 7), false);
                break;

            case ReplyCode.RPL_ENDOFWHOWAS:
                OnWhowas?.Invoke(User.Empty, "", true);
                break;

            case ReplyCode.RPL_UMODEIS:
            {
                //First drop the '+'
                string     chars = tokens[3].Substring(1);
                UserMode[] modes = Rfc2812Util.UserModesToArray(chars);
                OnUserModeRequest?.Invoke(modes);
            }
            break;

            case ReplyCode.RPL_CHANNELMODEIS:
                try
                {
                    ChannelModeInfo[] modes = ChannelModeInfo.ParseModes(tokens, 4);
                    OnChannelModeRequest?.Invoke(tokens[3], modes);
                }
                catch (Exception)
                {
                    OnError.Fire(this, new ErrorMessageEventArgs(ReplyCode.UnparseableMessage, CondenseStrings(tokens, 0)));
                    Debug.WriteLineIf(Rfc2812Util.IrcTrace.TraceWarning, "[" + Thread.CurrentThread.Name + "] Listener::ParseReply() Bad IRC MODE string=" + tokens[0]);
                }
                break;

            case ReplyCode.RPL_BANLIST:
                OnChannelList?.Invoke(tokens[3], ChannelMode.Ban, tokens[4], Rfc2812Util.UserFromString(tokens[5]), Convert.ToInt64(tokens[6], CultureInfo.InvariantCulture), false);
                break;

            case ReplyCode.RPL_ENDOFBANLIST:
                OnChannelList?.Invoke(tokens[3], ChannelMode.Ban, "", User.Empty, 0, true);
                break;

            case ReplyCode.RPL_INVITELIST:
                OnChannelList?.Invoke(tokens[3], ChannelMode.Invitation, tokens[4], Rfc2812Util.UserFromString(tokens[5]), Convert.ToInt64(tokens[6]), false);
                break;

            case ReplyCode.RPL_ENDOFINVITELIST:
                OnChannelList?.Invoke(tokens[3], ChannelMode.Invitation, "", User.Empty, 0, true);
                break;

            case ReplyCode.RPL_EXCEPTLIST:
                OnChannelList?.Invoke(tokens[3], ChannelMode.Exception, tokens[4], Rfc2812Util.UserFromString(tokens[5]), Convert.ToInt64(tokens[6]), false);
                break;

            case ReplyCode.RPL_ENDOFEXCEPTLIST:
                OnChannelList?.Invoke(tokens[3], ChannelMode.Exception, "", User.Empty, 0, true);
                break;

            case ReplyCode.RPL_UNIQOPIS:
                OnChannelList?.Invoke(tokens[3], ChannelMode.ChannelCreator, tokens[4], User.Empty, 0, true);
                break;

            case ReplyCode.RPL_VERSION:
                OnVersion?.Invoke(CondenseStrings(tokens, 3));
                break;

            case ReplyCode.RPL_TIME:
                OnTime?.Invoke(CondenseStrings(tokens, 3));
                break;

            case ReplyCode.RPL_INFO:
                OnInfo?.Invoke(CondenseStrings(tokens, 3), false);
                break;

            case ReplyCode.RPL_ENDOFINFO:
                OnInfo?.Invoke(CondenseStrings(tokens, 3), true);
                break;

            case ReplyCode.RPL_ADMINME:
            case ReplyCode.RPL_ADMINLOC1:
            case ReplyCode.RPL_ADMINLOC2:
            case ReplyCode.RPL_ADMINEMAIL:
                OnAdmin?.Invoke(RemoveLeadingColon(CondenseStrings(tokens, 3)));
                break;

            case ReplyCode.RPL_LUSERCLIENT:
            case ReplyCode.RPL_LUSEROP:
            case ReplyCode.RPL_LUSERUNKNOWN:
            case ReplyCode.RPL_LUSERCHANNELS:
            case ReplyCode.RPL_LUSERME:
                OnLusers?.Invoke(RemoveLeadingColon(CondenseStrings(tokens, 3)));
                break;

            case ReplyCode.RPL_LINKS:
                OnLinks?.Invoke(tokens[3],                                                              //mask
                                tokens[4],                                                              //hostname
                                int.Parse(RemoveLeadingColon(tokens[5]), CultureInfo.InvariantCulture), //hopcount
                                CondenseStrings(tokens, 6), false);
                break;

            case ReplyCode.RPL_ENDOFLINKS:
                OnLinks?.Invoke(String.Empty, String.Empty, -1, String.Empty, true);
                break;

            case ReplyCode.RPL_STATSLINKINFO:
            case ReplyCode.RPL_STATSCOMMANDS:
            case ReplyCode.RPL_STATSUPTIME:
            case ReplyCode.RPL_STATSOLINE:
                OnStats?.Invoke(GetQueryType(code), RemoveLeadingColon(CondenseStrings(tokens, 3)), false);
                break;

            case ReplyCode.RPL_ENDOFSTATS:
                OnStats?.Invoke(Rfc2812Util.CharToStatsQuery(tokens[3][0]), RemoveLeadingColon(CondenseStrings(tokens, 4)), true);
                break;

            default:
                HandleDefaultReply(code, tokens);
                break;
            }
        }