VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Parser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'Used with permission from author. Slightly modifided with use
'with BWW-IRC

Option Explicit
'sIRCPaser class , version 1 by Sahand ** updated version **
'This one works a lot better and has less bugs check it out if you liked the first one!
'send me your comments/suggestions/compliments ... to sstiger3000@yahoo.com
'make sure to declare the instance of the class using the 'Withevents' statement
'or you won't get anything useful out of it!
'changes from version 0.4 are that 5 of error events are now in one
' "OnServerError" which has an attribute called errortype that you can
'use to find out what kind of error it was
'in this version every event has the "RealLine" parameter which is the unparsed
'line , in case you want to use in some other way(like logging e.g)
'have fun! and make sure to vote for it and send me your suggstions
'because i want to continue this project.
'You are free to use this file in your projects(give me credits if u like anyway :)

    Public Enum CTCPTypes
        CTCPPing = 1013
        CTCPVersion = 1014
        CTCPTime = 1015
    End Enum

    Public Enum IRCErrors
        ircUnknownCommand = 421
        ircUnKnownName = 401
        ircNotInChannel = 442
        ircChannelIsBanned = 474
        ircNotOperator = 482
        ircNotEnoughParams = 461
        ircNoSuchChannel = 403
        ircNoTextToSend = 412
    End Enum

    Public Enum IRCConstants
        ircNotRegistered = 451
        ircNickExist = 433
        ircMOTD = 372
        ircWelcome = 1
        ircServerNumUsers = 251
        ircEndOfMOTD = 376
        ircStartofMOTD = 375
        ircChannelNames = 353
        ircEOFChannelNames = 366
        ircServerNumOfChannels = 254
        ircPersonJoin = 100
        ircPrivateMsg = 1000
        ircChannelMsg = 1003
        ircPrivateNotice = 1004
        ircChannelAction = 1019
        ircPersonAction = 1020
        ircChannelNotice = 1005
        ircNickChange = 1006
        ircPersonHost = 311
        ircPersonChans = 319
        ircPersonServer = 312
        ircPersonIdleTime = 317
        ircPersonPart = 1007
        ircPersonQuit = 1008
        ircEndOfWhois = 318
        ircServerNotice = 1009
        ircChannelMode = 1011
        ircChannelTopicChange = 1012
        ircChannelTopic = 332
        ircCTCPRequest = 1013
        ircPersonIsAway = 301
        ircAwayStatChange = 1014
        ircServerError = 1015
        ircKickedFromChan = 1016
    End Enum

    Public Event OnServerMOTD(ByVal Server As String, ByVal Nickname As String, ByVal Message As String, ByVal RealLine As String)
    Public Event OnServerEOFMOTD(ByVal Server As String, ByVal Nickname As String, ByVal Message As String, ByVal RealLine As String)
    Public Event OnServerStartOfMOTD(ByVal Server As String, ByVal Nickname As String, ByVal Message As String, ByVal RealLine As String)
    Public Event OnServerWelcome(ByVal Server As String, ByVal Nickname As String, ByVal Message As String, ByVal RealLine As String)
    Public Event OnServerNumbers(ByVal Server As String, ByVal Nickname As String, ByVal Message As String, ByVal NumOfUsers As Long, ByVal NumOfInvUsers As Long, ByVal NumOfServers As Long, ByVal RealLine As String)
    Public Event OnServerNumOfChan(ByVal Server As String, ByVal Nickname As String, ByVal NumOfChans As Long, ByVal RealLine As String)
    Public Event OnChannelNames(ByVal Server As String, ByVal Nickname As String, ByVal Channel As String, ByVal People As String, ByVal RealLine As String)
    Public Event OnServerNotice(ByVal Server As String, ByVal Nickname As String, ByVal Message As String, ByVal RealLine As String)
    Public Event OnEOFChannelNames(ByVal Server As String, ByVal Nickname As String, ByVal Channel As String, ByVal RealLine As String)
    Public Event OnPersonJoin(ByVal Nickname As String, ByVal HostName As String, ByVal Channel As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnPrivateMsg(ByVal SenderNick As String, ByVal SenderHost As String, ByVal RecvNick As String, ByVal Message As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnPrivateAction(ByVal SenderNick As String, ByVal SenderHost As String, ByVal RecvNick As String, ByVal Action As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnChannelMsg(ByVal SenderNick As String, ByVal SenderHost As String, ByVal RecvChannel As String, ByVal Message As String, ByVal RealLine As String)
    Public Event OnChannelAction(ByVal SenderNick As String, ByVal SenderHost As String, ByVal RecvChannel As String, ByVal Action As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnPrivateNotice(ByVal SenderNick As String, ByVal SenderHost As String, ByVal RecvNick As String, ByVal Message As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnChannelNotice(ByVal SenderNick As String, ByVal SenderHost As String, ByVal RecvChannel As String, ByVal Message As String, ByVal Ideneted As Boolean, ByVal RealLine As String)
    Public Event OnNickChange(ByVal OldNick As String, ByVal NewNick As String, ByVal HostName As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnPersonHost(ByVal Nickname As String, ByVal UserName As String, ByVal RealName As String, ByVal PersonServer As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnPersonChans(ByVal Nickname As String, ByVal Channels As String, ByVal RealLine As String)
    Public Event OnPersonServer(ByVal Nickname As String, ByVal PersonServer As String, ByVal ServerDescription As String, ByVal RealLine As String)
    Public Event OnPersonIdleTime(ByVal Nickname As String, ByVal SecondsIdle As String, ByVal LogonTime As String, ByVal RealLine As String)
    Public Event OnPersonPart(ByVal Nickname As String, ByVal HostName As String, ByVal Channel As String, ByVal reason As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnPersonQuit(ByVal Nickname As String, ByVal HostName As String, ByVal reason As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnPersonKick(ByVal KickedNick As String, ByVal KickerNick As String, ByVal KickerHost As String, ByVal Channel As String, ByVal reason As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnChannelMode(ByVal Nickname As String, ByVal HostName As String, ByVal Channel As String, ByVal Mode As String, ByVal Who As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnChannelTopicChange(ByVal Nickname As String, ByVal HostName As String, ByVal Channel As String, ByVal Topic As String, ByVal Idented As Boolean, ByVal RealLine As String)
    Public Event OnChannelTopic(ByVal Server As String, ByVal Channel As String, ByVal Topic As String, ByVal RealLine As String)
    Public Event OnCTCPRequest(ByVal Nickname As String, ByVal HostName As String, ByVal Idented As Boolean, ByVal CTCPType As CTCPTypes, ByVal RealLine As String, ByVal PingID As String)
    Public Event onPersonIsAway(ByVal Nickname As String, ByVal Server As String, ByVal PersonAway As String, ByVal reason As String, ByVal RealLine As String)
    Public Event OnAwayStatChange(ByVal Server As String, ByVal Nickname As String, ByVal AwayOn As Boolean, ByVal RealLine As String)
    Public Event OnServerError(ByVal Nickname As String, ByVal Server As String, ByVal ErrorType As IRCErrors, ByVal ExtraInfo As String, ByVal RealLine As String)
    Public Event OnEndOfWhois(ByVal Nickname As String, ByVal RealLine As String)
    Public Event OnNickExist(ByVal Server As String, ByVal Nickname As String, ByVal ExistingNick As String, ByVal RealLine As String)
    Public Event OnClosingLink(ByVal reason As String, ByVal Nickname As String, ByVal RealLine As String)
    Public Event OnServerPing(ByVal PingID As String, ByVal RealLine As String)
    Public Event OnNotRegistered(ByVal Server As String, ByVal RealLine As String)
    Public Event UnknownIncome(ByVal Line As String)

    Private TempStr1() As String
    Private TempStr2() As String
    Private TempStr3() As String
    Private Idented As Boolean

    Private MsgType As IRCConstants
    Private errorCode As IRCErrors

    Public Property Get LastMsgType() As IRCConstants
            LastMsgType = MsgType
    End Property

    Public Property Get LastError() As IRCErrors
            LastError = errorCode
    End Property
    'returns the number of lines in the specified text
    'and calls the CheckLine function for each of the lines
    Private Function GetNumOfCRFL(ByVal text As String) As Long
        Dim LoopIndex As Long, TmpText As String
        LoopIndex = 0
        TmpText = text
        While InStr(TmpText, vbCrLf) <> 0
            TmpText = Mid(TmpText, InStr(TmpText, vbCrLf) + 2)
            LoopIndex = LoopIndex + 1
        Wend
        GetNumOfCRFL = LoopIndex
    End Function

    Public Sub ProcessText(ByRef text As String)
        Dim LoopIndex As Long, TmpText() As String
        TmpText = Split(text, vbCrLf)
        Do
            Call CheckLine(TmpText(LoopIndex))
            LoopIndex = LoopIndex + 1
        Loop While LoopIndex < UBound(TmpText)
    End Sub

    'checks the line and raises events
    Private Function CheckLine(ByVal Line As String) As Boolean
    On Error Resume Next
        If Line = "" Then Exit Function
        If GetNumOfCRFL(Line) > 0 Then
            CheckLine = False
            Exit Function
        End If
        TempStr1 = Split(Mid(Line, 2), ":", 2)
        If UBound(TempStr1) < 1 Then
            TempStr2 = Split(TempStr1(0), " ", 5)
            If UBound(TempStr2) < 3 Then
                If UCase(TempStr2(1)) = "PART" Then
                    MsgType = IRCConstants.ircPersonPart
                    TempStr3 = Split(TempStr2(0), "!", 2)
                    If UBound(TempStr3) < 1 Then
                        RaiseEvent UnknownIncome(Line)
                        Exit Function
                    End If
                    If InStr(TempStr3(1), "~") Then
                        TempStr3(1) = Mid(TempStr3(1), 2)
                        Idented = False
                    Else
                        Idented = True
                    End If
                    RaiseEvent OnPersonPart(TempStr3(0), TempStr3(1), TempStr2(2), "", Idented, Line)
                End If
            End If
            If Val(TempStr2(1)) > 0 And Val(TempStr2(1)) < 5 Then
                MsgType = IRCConstants.ircWelcome
                RaiseEvent OnServerWelcome(TempStr2(0), TempStr2(2), TempStr2(3), Line)
            End If
            If UCase(TempStr2(1)) = "MODE" Then
                MsgType = IRCConstants.ircChannelMode
                TempStr3 = Split(TempStr2(0), "!", 2)
                If UBound(TempStr3) < 1 Then
                    RaiseEvent UnknownIncome(Line)
                    Exit Function
                End If
                If InStr(TempStr3(1), "~") Then
                    TempStr3(1) = Mid(TempStr3(1), 2)
                    Idented = False
                Else
                    Idented = True
                End If
                RaiseEvent OnChannelMode(TempStr3(0), TempStr3(1), TempStr2(2), TempStr2(3), TempStr2(4), Idented, Line)
            End If
        Else
            TempStr2 = Split(TempStr1(0), " ")
            If UBound(TempStr2) < 2 Then
                If UCase(Mid(Line, 1, 4)) = "PING" Then
                    RaiseEvent OnServerPing(TempStr1(1), Line)
                ElseIf UCase(Mid(Line, 1, 5)) = "ERROR" Then
                    TempStr3 = Split(TempStr1(1), " ")
                    RaiseEvent OnClosingLink(TempStr3(2), TempStr3(0), Line)
                    Exit Function
                Else
                    RaiseEvent UnknownIncome(Line)
                End If
            ElseIf UBound(TempStr2) = 2 Then
                If UCase(TempStr2(1)) = "JOIN" Then
                    MsgType = IRCConstants.ircPersonJoin
                    TempStr3 = Split(TempStr2(0), "!", 2)
                    If UBound(TempStr3) < 1 Then
                        RaiseEvent UnknownIncome(Line)
                        Exit Function
                    End If
                    If InStr(TempStr3(1), "~") Then
                        TempStr3(1) = Mid(TempStr3(1), 2)
                        Idented = False
                    Else
                        Idented = True
                    End If
                    RaiseEvent OnPersonJoin(TempStr3(0), TempStr3(1), TempStr1(1), Idented, Line)
                ElseIf UCase(TempStr2(1)) = "QUIT" Then
                    MsgType = IRCConstants.ircPersonQuit
                    TempStr3 = Split(TempStr2(0), "!", 2)
                    If UBound(TempStr3) < 1 Then
                        RaiseEvent UnknownIncome(Line)
                        Exit Function
                    End If
                    If InStr(TempStr3(1), "~") Then
                        TempStr3(1) = Mid(TempStr3(1), 2)
                        Idented = False
                    Else
                        Idented = True
                    End If
                    RaiseEvent OnPersonQuit(TempStr3(0), TempStr3(1), TempStr1(1), Idented, Line)
                ElseIf UCase(TempStr2(1)) = "NICK" Then
                    MsgType = IRCConstants.ircNickChange
                    TempStr3 = Split(TempStr2(0), "!", 2)
                    If UBound(TempStr3) < 1 Then
                        RaiseEvent UnknownIncome(Line)
                        Exit Function
                    End If
                    If InStr(TempStr3(1), "~") Then
                        TempStr3(1) = Mid(TempStr3(1), 2)
                        Idented = False
                    Else
                        Idented = True
                    End If
                    RaiseEvent OnNickChange(TempStr3(0), TempStr1(1), TempStr3(1), Idented, Line)
                End If
            ElseIf UBound(TempStr2) > 2 Then
                If UCase(TempStr2(1)) = "PART" Then
                    MsgType = IRCConstants.ircPersonPart
                    TempStr3 = Split(TempStr2(0), "!", 2)
                    If UBound(TempStr3) < 1 Then
                        RaiseEvent UnknownIncome(Line)
                        Exit Function
                    End If
                    If InStr(TempStr3(1), "~") Then
                        TempStr3(1) = Mid(TempStr3(1), 2)
                        Idented = False
                    Else
                        Idented = True
                    End If
                    RaiseEvent OnPersonPart(TempStr3(0), TempStr3(1), TempStr2(2), TempStr1(1), Idented, Line)
                End If
                If UCase(TempStr2(1)) = "KICK" Then
                    MsgType = IRCConstants.ircKickedFromChan
                    TempStr3 = Split(TempStr2(0), "!", 2)
                    If UBound(TempStr3) < 1 Then
                        RaiseEvent UnknownIncome(Line)
                        Exit Function
                    End If
                    If InStr(TempStr3(1), "~") Then
                        TempStr3(1) = Mid(TempStr3(1), 2)
                        Idented = False
                    Else
                        Idented = True
                    End If
                    RaiseEvent OnPersonKick(TempStr2(3), TempStr3(0), TempStr3(1), TempStr2(2), TempStr1(1), Idented, Line)
                End If
                If UCase(TempStr2(1)) = "TOPIC" Then
                    MsgType = IRCConstants.ircChannelTopicChange
                    TempStr3 = Split(TempStr2(0), "!", 2)
                    If UBound(TempStr3) < 1 Then
                        RaiseEvent UnknownIncome(Line)
                        Exit Function
                    End If
                    If InStr(TempStr3(1), "~") Then
                        TempStr3(1) = Mid(TempStr3(1), 2)
                        Idented = False
                    Else
                        Idented = True
                    End If
                    RaiseEvent OnChannelTopicChange(TempStr3(0), TempStr3(1), TempStr2(2), TempStr1(1), Idented, Line)
                End If
                If UCase(TempStr2(1)) = "PRIVMSG" Then
                    If InStr(TempStr2(2), "#") <> 0 Then
                        MsgType = IRCConstants.ircChannelMsg
                        TempStr3 = Split(TempStr2(0), "!", 2)
                        If UBound(TempStr3) < 1 Then
                            RaiseEvent UnknownIncome(Line)
                            Exit Function
                        End If
                        If InStr(TempStr3(1), "~") Then
                            TempStr3(1) = Mid(TempStr3(1), 2)
                            Idented = False
                        Else
                            Idented = True
                        End If
                        If Mid(TempStr1(1), 1, 1) = Chr(1) And UCase(Mid(TempStr1(1), 2, 5)) = "ACTION" Then
                            MsgType = ircChannelAction
                            
                            RaiseEvent OnChannelAction(TempStr3(0), TempStr3(1), TempStr2(2), Left(Right(TempStr1(1), Len(TempStr1(1)) - 7), Len(Right(TempStr1(1), Len(TempStr1(1)) - 7)) - 1), Idented, Line)
                            Exit Function
                        End If
                        RaiseEvent OnChannelMsg(TempStr3(0), TempStr3(1), TempStr2(2), TempStr1(1), Line)
                    Else
                        MsgType = IRCConstants.ircPrivateMsg
                        TempStr3 = Split(TempStr2(0), "!", 2)
                        If UBound(TempStr3) < 1 Then
                            RaiseEvent UnknownIncome(Line)
                            Exit Function
                        End If
                        If InStr(TempStr3(1), "~") Then
                            TempStr3(1) = Mid(TempStr3(1), 2)
                            Idented = False
                        Else
                            Idented = True
                        End If
                        If InStr(TempStr1(1), Chr(1) & "PING") <> 0 Then
                            MsgType = IRCConstants.ircCTCPRequest
                            RaiseEvent OnCTCPRequest(TempStr3(0), TempStr3(1), Idented, CTCPTypes.CTCPPing, Line, Mid(Line, InStr(Line, Chr(1) & "PING") + 6, Len(Mid(Line, InStr(Line, Chr(1) & "PING") + 6)) - 1))
                            Exit Function
                        ElseIf Mid(TempStr1(1), 1, 1) = Chr(1) And UCase(Mid(TempStr1(1), 2, 6)) = "ACTION" Then
                            MsgType = ircPersonAction
                            RaiseEvent OnPrivateAction(TempStr3(0), TempStr3(1), TempStr2(2), Left(Right(TempStr1(1), Len(TempStr1(1)) - 7), Len(Right(TempStr1(1), Len(TempStr1(1)) - 7)) - 1), Idented, Line)
                            Exit Function
                        ElseIf TempStr1(1) = Chr(1) & "VERSION" & Chr(1) Then
                            MsgType = IRCConstants.ircCTCPRequest
                            RaiseEvent OnCTCPRequest(TempStr3(0), TempStr3(1), Idented, CTCPTypes.CTCPVersion, Line, "")
                            Exit Function
                        ElseIf TempStr1(1) = Chr(1) & "TIME" & Chr(1) Then
                            MsgType = IRCConstants.ircCTCPRequest
                            RaiseEvent OnCTCPRequest(TempStr3(0), TempStr3(1), Idented, CTCPTypes.CTCPTime, Line, "")
                            Exit Function
                        End If
                        RaiseEvent OnPrivateMsg(TempStr3(0), TempStr3(1), TempStr2(2), TempStr1(1), Idented, Line)
                    End If
                ElseIf UCase(TempStr2(1)) = "NOTICE" Then
                    If InStr(TempStr2(2), "#") <> 0 Then
                        MsgType = IRCConstants.ircChannelNotice
                        TempStr3 = Split(TempStr2(0), "!", 2)
                        If UBound(TempStr3) < 1 Then
                            RaiseEvent UnknownIncome(Line)
                            Exit Function
                        End If
                        If InStr(TempStr3(1), "~") Then
                            TempStr3(1) = Mid(TempStr3(1), 2)
                            Idented = False
                        Else
                            Idented = True
                        End If
                        RaiseEvent OnChannelNotice(TempStr3(0), TempStr3(1), TempStr2(2), TempStr1(1), Idented, Line)
                    Else
                        MsgType = IRCConstants.ircPrivateNotice
                        TempStr3 = Split(TempStr2(0), "!", 2)
                        If UBound(TempStr3) < 1 Then
                            MsgType = IRCConstants.ircServerNotice
                            RaiseEvent OnServerNotice(TempStr3(0), TempStr2(2), TempStr1(1), Line)
                            Exit Function
                        End If
                        If InStr(TempStr3(1), "~") Then
                            TempStr3(1) = Mid(TempStr3(1), 2)
                            Idented = False
                        Else
                            Idented = True
                        End If
                        RaiseEvent OnPrivateNotice(TempStr3(0), TempStr3(1), TempStr2(2), TempStr1(1), Idented, Line)
                    End If
                End If
            End If
            If Val(TempStr2(1)) <> 0 Then
                Select Case Val(TempStr2(1))
                    Case 372
                        MsgType = IRCConstants.ircMOTD
                        RaiseEvent OnServerMOTD(TempStr2(0), TempStr2(2), TempStr1(1), Line)
                    Case Is < 5
                        MsgType = IRCConstants.ircWelcome
                        RaiseEvent OnServerWelcome(TempStr2(0), TempStr2(2), TempStr1(1), Line)
                    Case 251
                        MsgType = IRCConstants.ircServerNumUsers
                        TempStr3 = Split(TempStr1(1), " ")
                        RaiseEvent OnServerNumbers(TempStr2(0), TempStr2(2), TempStr1(1), Val(TempStr3(2)), Val(TempStr3(5)), Val(TempStr3(8)), Line)
                    Case 375
                        MsgType = IRCConstants.ircStartofMOTD
                        RaiseEvent OnServerStartOfMOTD(TempStr2(0), TempStr2(2), TempStr1(1), Line)
                    Case 376
                        MsgType = IRCConstants.ircEndOfMOTD
                        RaiseEvent OnServerEOFMOTD(TempStr2(0), TempStr2(2), TempStr1(1), Line)
                    Case 353
                        MsgType = IRCConstants.ircChannelNames
                        RaiseEvent OnChannelNames(TempStr2(0), TempStr2(2), TempStr2(4), TempStr1(1), Line)
                    Case 366
                        MsgType = IRCConstants.ircEOFChannelNames
                        RaiseEvent OnEOFChannelNames(TempStr2(0), TempStr2(2), TempStr2(3), Line)
                    Case 254
                        MsgType = IRCConstants.ircServerNumOfChannels
                        RaiseEvent OnServerNumOfChan(TempStr2(0), TempStr2(2), Val(TempStr2(3)), Line)
                    Case 421
                        MsgType = IRCConstants.ircServerError
                        errorCode = IRCErrors.ircUnknownCommand
                        RaiseEvent OnServerError(TempStr2(0), TempStr2(2), IRCErrors.ircUnknownCommand, TempStr2(3), Line)
                    Case 401
                        MsgType = IRCConstants.ircServerError
                        RaiseEvent OnServerError(TempStr2(0), TempStr2(2), IRCErrors.ircUnKnownName, TempStr2(3), Line)
                    Case 311
                        MsgType = IRCConstants.ircPersonHost
                        If InStr(TempStr2(4), "~") Then
                            TempStr2(4) = Mid(TempStr2(4), 2)
                            Idented = False
                        Else
                            Idented = True
                        End If
                        RaiseEvent OnPersonHost(TempStr2(3), TempStr2(4), TempStr1(1), TempStr2(5), Idented, Line)
                    Case 319
                        MsgType = IRCConstants.ircPersonChans
                        RaiseEvent OnPersonChans(TempStr2(3), TempStr1(1), Line)
                    Case 312
                        MsgType = IRCConstants.ircPersonServer
                        RaiseEvent OnPersonServer(TempStr2(3), TempStr2(4), TempStr1(1), Line)
                    Case 317
                        MsgType = IRCConstants.ircPersonIdleTime
                        RaiseEvent OnPersonIdleTime(TempStr2(3), TempStr2(4), TempStr2(5), Line)
                    Case 318
                        MsgType = IRCConstants.ircEndOfWhois
                        RaiseEvent OnEndOfWhois(TempStr2(3), Line)
                    Case 433
                        MsgType = IRCConstants.ircNickExist
                        RaiseEvent OnNickExist(TempStr2(0), TempStr2(2), TempStr2(3), Line)
                    Case 442
                        MsgType = IRCConstants.ircServerError
                        errorCode = IRCErrors.ircNotInChannel
                        RaiseEvent OnServerError(TempStr2(2), TempStr2(0), IRCErrors.ircNotInChannel, TempStr2(3), Line)
                    Case 474
                        MsgType = IRCConstants.ircServerError
                        errorCode = IRCErrors.ircChannelIsBanned
                        RaiseEvent OnServerError(TempStr2(2), TempStr2(0), IRCErrors.ircChannelIsBanned, TempStr2(3), Line)
                    Case 332
                        MsgType = IRCConstants.ircChannelTopic
                        RaiseEvent OnChannelTopic(TempStr2(0), TempStr2(3), TempStr1(1), Line)
                    Case 482
                        MsgType = IRCConstants.ircServerError
                        errorCode = IRCErrors.ircNotOperator
                        RaiseEvent OnServerError(TempStr2(2), TempStr2(0), IRCErrors.ircNotOperator, TempStr2(3), Line)
                    Case 403
                        MsgType = IRCConstants.ircServerError
                        errorCode = IRCErrors.ircNoSuchChannel
                        RaiseEvent OnServerError(TempStr2(2), TempStr2(0), IRCErrors.ircNoSuchChannel, TempStr2(3), Line)
                    Case 451
                        MsgType = IRCConstants.ircNotRegistered
                        RaiseEvent OnNotRegistered(TempStr2(0), Line)
                    Case 301
                        MsgType = IRCConstants.ircPersonIsAway
                        RaiseEvent onPersonIsAway(TempStr2(2), TempStr2(0), TempStr2(3), TempStr1(1), Line)
                    Case 306
                        MsgType = IRCConstants.ircAwayStatChange
                        RaiseEvent OnAwayStatChange(TempStr2(2), TempStr2(0), True, Line)
                    Case 305
                        MsgType = IRCConstants.ircAwayStatChange
                        RaiseEvent OnAwayStatChange(TempStr2(2), TempStr2(0), False, Line)
                    Case 412
                        MsgType = IRCConstants.ircServerError
                        errorCode = IRCErrors.ircNoTextToSend
                        RaiseEvent OnServerError(TempStr2(2), TempStr2(0), IRCErrors.ircNoTextToSend, TempStr2(3), Line)
                    Case 461
                        MsgType = IRCConstants.ircServerError
                        errorCode = IRCErrors.ircNotEnoughParams
                        RaiseEvent OnServerError(TempStr2(2), TempStr2(0), IRCErrors.ircNotEnoughParams, TempStr2(3), Line)
                End Select
            End If
        End If
    End Function
