VERSION 5.00
Begin VB.Form frmEvents 
   Caption         =   "BWW EVENT HANDLER"
   ClientHeight    =   795
   ClientLeft      =   720
   ClientTop       =   1440
   ClientWidth     =   3420
   LinkTopic       =   "Form1"
   ScaleHeight     =   795
   ScaleWidth      =   3420
   Visible         =   0   'False
End
Attribute VB_Name = "frmEvents"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

'This from is simply used to handle IRC events
'It is a separate form so that the programming code is easier to naviage
Dim WithEvents IRC As Parser
Attribute IRC.VB_VarHelpID = -1

Private Sub Form_Load()
    Set IRC = New Parser
End Sub

Private Sub IRC_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)
'Sub dosnt work
'DisplayActionInChannel actions, SenderNick, RecvChannel
End Sub

Private Sub IRC_OnChannelMsg(ByVal SenderNick As String, ByVal SenderHost As String, ByVal RecvChannel As String, ByVal Message As String, ByVal RealLine As String)
    Dim Msg() As String
    'remove words from message that are in the blocklist if true
    If frmmain.chkBlock = 1 Then Message = RemoveWords(Message)
    
    'if message is an action
    If InStr(1, Message, Chr(1) + "ACTION") Then
        Msg = Split(Message, Chr(1))
        Msg = Split(Msg(1), "ACTION")
        DisplayActionInChannel Msg(1), SenderNick, UCase(RecvChannel)
    Else 'It is a normal message
        DisplayMessageInChannel Message, SenderNick, UCase(RecvChannel), vbBlack
    End If
End Sub

Private Sub IRC_OnChannelNames(ByVal Server As String, ByVal Nickname As String, ByVal Channel As String, ByVal People As String, ByVal RealLine As String)
    'call listuser sub
    PeopleUpdate People, Channel
End Sub

'On channel notice is recieved
Private Sub IRC_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)
If frmmain.chkChannelInfo.value = 1 Then Display Message, frmmain.allChannels(UCase(RecvChannel)).rtbView, &H8000&, False, False, True, False
End Sub

'On a channel topic is recieved
Private Sub IRC_OnChannelTopic(ByVal Server As String, ByVal Channel As String, ByVal Topic As String, ByVal RealLine As String)
If frmmain.chkChannelInfo.value = 1 Then Display Topic, frmmain.allChannels(UCase(Channel)).rtbView, &H8000&, False, False, True, False
End Sub

'When a person joins
Private Sub IRC_OnPersonJoin(ByVal Nickname As String, ByVal HostName As String, ByVal Channel As String, ByVal Idented As Boolean, ByVal RealLine As String)
    If Not Nickname = frmmain.txtNick.text Then
        PersonAdd Nickname, Channel
        If frmmain.chkUserstaus.value = 1 Then Display Nickname + " joined", frmmain.allChannels.Item(UCase(Channel)).rtbView, vbRed, False, False, True, False
    End If
End Sub

'When a person is kicked from the channel
Private Sub IRC_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)
    'if person kicked remove them
    If Not KickedNick = frmmain.txtNick.text Then
    PersonRemove KickedNick, Channel
    If frmmain.chkUserstaus.value = 1 Then Display KickedNick + " kicked by " + KickerNick, frmmain.allChannels.Item(UCase(Channel)).rtbView, vbRed, False, False, True, False
    End If
End Sub

'When person parts/leaves a channel
Private Sub IRC_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)
    'if person parts remove them
    If Not Nickname = frmmain.txtNick.text Then
    PersonRemove Nickname, Channel
    If frmmain.chkUserstaus.value = 1 Then Display Nickname + " has left - " + reason, frmmain.allChannels.Item(UCase(Channel)).rtbView, vbRed, False, False, True, False
    End If
End Sub

'Dosnt work
Private Sub IRC_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)
DisplayActionInPrivate Action, SenderNick
End Sub

'When a private message is recieved
Private Sub IRC_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)
    'Allow it or not
    Dim Accept As Boolean
    
    'If form dosnt exist
    If Not frmmain.allPrivates.Exists(SenderNick) Then
    'Does user want to see the message
    If frmmain.chkAutoPriv = 0 Then Accept = MsgBox("Do you want to accept a message from " + SenderNick + "?", vbOKCancel, "Acceppt connection") Else Accept = True
    'Accept is true then load a form or exit the sub
    If Accept = True Then LoadPrivateForm (SenderNick) Else Exit Sub
    End If
    
    Dim Msg() As String
    'remove words from message that are in the blocklist if true
    If frmmain.chkBlock = 1 Then Message = RemoveWords(Message)
    
    'if message is an action
    If InStr(1, Message, Chr(1) + "ACTION") Then
        Msg = Split(Message, Chr(1))
        Msg = Split(Msg(1), "ACTION")
        DisplayActionInPrivate Msg(1), SenderNick
        Else 'It is a normal message
        DisplayMessageInPrivate Message, SenderNick, vbBlack
    End If

End Sub

Private Sub IRC_OnServerEOFMOTD(ByVal Server As String, ByVal Nickname As String, ByVal Message As String, ByVal RealLine As String)
frmmain.Connected
End Sub

'ON PING 2 REPLY PONG
Private Sub IRC_OnServerPing(ByVal PingID As String, ByVal RealLine As String)
    'Send a PONG
    frmmain.SendData "PONG " + PingID
End Sub

Private Sub IRC_OnServerWelcome(ByVal Server As String, ByVal Nickname As String, ByVal Message As String, ByVal RealLine As String)
    'display server welcome message
    frmmain.Display Message, vbBlue
End Sub

Public Sub phaseIRC(text As String)
    'Sub to phase data
    IRC.ProcessText (text)
End Sub

'IRC UNKNOW SERVER MESSAGE
Private Sub IRC_UnknownIncome(ByVal Line As String)
    'If an unknow message comes though display it in the consol windows
    frmmain.Display Line, vbBlue
End Sub