- Ја почнал/а темата
- #1
HijackHacker
Gaining Experience
Правам ИРЦ клиент ама кога се поврзувам со канал вели
Овде го прави проблемот: Case "JOIN" (види во кодот)
Мислам дека сака да каже дека во text1 нема доволно место, ама како да го заобиколам ова?
Код:
[I]"Run-time error '9':
Subscript out of range.[/I]
Код:
Private Sub sckIRC_OnDataArrival(ByVal bytesTotal As Long)
'variables for everything
Dim strData As String, arrData() As String, i As Long
Dim arrDat2() As String, arrDat3() As String
Dim User As String, Channel As String, Text As String, sName As String
Dim TempVal As Long
Dim bRaised As Boolean
'Get the data
sckIRC.GetData strData, vbString
'Seperate the data
arrData = Split(strData, vbCrLf)
'Loop through the data
For i = 0 To UBound(arrData) - 1
'Just a small fix...
If UCase$(Left$(arrData(i), 3)) = "RC." Then arrData(i) = ":i" & arrData(i)
'Split all of the data as necessary
arrDat2 = Split(arrData(i), " ")
arrDat3 = Split(arrData(i), ":", 3)
If UBound(arrDat2) >= 1 Then
Select Case UCase$(arrDat2(1))
Case "PRIVMSG"
'if a PRIVMSG is recieved
'Get all of the data
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Channel = arrDat2(2)
Text = arrDat3(2)
If Left$(Text, 1) = Chr$(1) And Right$(Text, 1) = Chr$(1) Then
'If it is a CTCP get all of the data for it
sName = Mid$(Text, 2, Len(Split(Text, " ")(0)) - 1)
TempVal = Len(sName) + 3
Text = Mid$(Text, TempVal, Len(Text) - TempVal - 1)
Select Case UCase(sName)
Case "ACTION"
'If it is an action, raise the event for ACTION
RaiseEvent OnACTION(User, Channel, Text)
Case Else
'If it's a CTCP raise the event for a CTCP
RaiseEvent OnCTCP(User, Channel, sName, Text)
End Select
Else
'Raise the event for a PRIVMSG
RaiseEvent OnPRIVMSG(User, Channel, Text)
End If
Case "NOTICE"
'If a notice is recieved
'Get all of the data needed and raise the event
If arrDat2(0) Like "*!*@*" Then
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Else
User = Mid$(arrDat2(0), 2, Len(arrDat2(2)) - 2)
End If
Channel = arrDat2(2)
Text = arrDat3(2)
RaiseEvent OnNOTICE(User, Channel, Text)
[B][SIZE="4"]Case "JOIN"[/SIZE][/B]
'If a user joins a channel
'get the data and raise the event
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Channel = arrDat3(2)
RaiseEvent OnJOIN(User, Channel)
Case "MODE"
'If a Mode is set
'Get the data and raise the event
'NOT 100% FINISHED!!!!!
If arrDat2(0) Like "*!*@*" Then
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Else
User = Mid$(arrDat2(0), 2, Len(arrDat2(0)) - 2)
End If
Channel = arrDat2(2)
Text = arrDat2(3)
On Error Resume Next
sName = Split(arrData(i), " ", 5)(4)
RaiseEvent OnMODE(User, Channel, Text, sName)
Case "TOPIC"
'if the topic of a channel is changed
'get the data and raise the event
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Channel = arrDat2(2)
Text = arrDat3(2)
RaiseEvent OnTOPIC(User, Channel, Text)
Case "KICK"
'if a user is kicked
'get the data and raise the event
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Channel = arrDat2(2)
name = arrDat2(3)
Text = arrDat3(2)
RaiseEvent OnKICK(User, Channel, name, Text)
Case "PART"
'if a user parts
'get the data and raise the event
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Channel = arrDat2(2)
On Error Resume Next
Text = arrDat3(2)
RaiseEvent OnPART(User, Channel, Text)
Case "NICK"
'If a user changes his/her nickname
'get the data and raise the event
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Text = arrDat3(2)
RaiseEvent OnNICK(User, Text)
Case "QUIT"
'if a user quits IRC
'get the data and raise the event
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Text = arrDat3(2)
RaiseEvent OnQUIT(User, Text)
Case "INVITE"
'if you are invited to a channel
'get the data and raise the event
User = Mid$(arrDat2(0), 2, InStr(arrDat2(0), "!") - 2)
Text = arrDat3(2)
RaiseEvent OnINVITE(User, Text)
Case Else
If UCase$(arrDat2(0)) = "PING" Then
'If a PING request is recieved
'reply to the request
sckIRC.SendData "PONG :" & arrDat3(1) & vbCrLf
ElseIf (UCase$(arrDat2(0)) = "ERROR") Or (UCase$(arrDat2(0)) = ":ERROR") Then
'If you are disconnected from the server
'close the socket and raise the event
sckIRC.CloseSocket
RaiseEvent Disconnect
ElseIf IsNumeric(UCase$(arrDat2(1))) Then
'if you recieve a numerical reply
'parse through them
'THIS PART IS NOT FINISHED!!!
'ONLY SMALL PARTS OF IT ARE!!!
'MUCH MORE IS NEEDED TO COMPLETE IT!!!
Select Case CLng(arrDat2(1))
'MOTD MESSAGES
Case RPL_STARTOFMOTD, RPL_MOTD, RPL_ENDOFMOTD, ERR_NOMOTD
'if it is an MOTD message
'get the data and raise the event
Text = arrDat3(2)
RaiseEvent OnMOTD(CLng(arrDat2(1)), Text)
'Connection
Case RPL_WELCOME
'if it is a Welcome message
'get the data and raise the events
RaiseEvent Connected
Text = arrDat3(2)
RaiseEvent OnWelcome(RPL_WELCOME, Text)
Case RPL_YOURHOST, RPL_CREATED ', RPL_MYINFO, RPL_BOUNCE
'If it is information about the server
'get the data and raise the event
Text = arrDat3(2)
RaiseEvent OnWelcome(CLng(arrDat2(1)), Text)
'WHO/WHOIS/WHOWAS
Case RPL_WHOISUSER
'if it is a WHOIS reply
'get the data and raise the event
Text = arrDat2(3) & " is " & arrDat2(4) & "@" & arrDat2(5) & " : " & arrDat3(2)
RaiseEvent OnWHOX(RPL_WHOISUSER, Text)
Case RPL_WHOISREGISTERED
'If it says the user is registered
'get the data and raise the event
Text = arrDat2(3) & " " & arrDat3(2)
RaiseEvent OnWHOX(RPL_WHOISREGISTERED, Text)
Case Else
'If the data is not already chosen
'get the data and raise the event
TempVal = CLng(arrDat2(1))
Text = Split(arrData(i), " ", 3)(2)
RaiseEvent OnRAW(TempVal, Text)
End Select
End If
End Select
End If
RaiseEvent Recieve(arrData(i))
Next i
End Sub