|
-
Aug 12th, 2010, 10:09 AM
#1
Thread Starter
Junior Member
5 lines of code, cant login to my IRC Bot
This used to work then suddenly it just stopped working, not sure if i changed something :/
the code that doesnt function is in red:
Code:
Private Sub sock_DataArrival(ByVal bytesTotal As Long)
Dim sRecv As String
Dim cmdl() As String
Dim cmd As String
Dim i As Integer
Sock.GetData sRecv ' Put the data recieved into the string
' Play ping pong with the server
If InStr(sRecv, "PING") = 1 Then
Sock.SendData "PONG " & Split(sRecv, " ")(1)
End If
'split the line up and get commands e.g argl(3) == .login amdl(4) == pass .... so on
cmdl = Split(sRecv, " ")
cmd = cmdl(3)
cmd = Replace(cmd, ":", "")
Text1.Text = Text1.Text & sRecv & vbCrLf 'so i know whats going on
If InStr(cmd, ".login") Then 'look for login command
If cmdl(4) = pass Then 'is pass = 16331633? next line
auth_user = cmdl(0) 'host name of the person with the correct pass now controlls the bot.
MsgBox "logged in!" 'debug, just so i know this has executed, it has not.
Else
MsgBox cmd & " " & cmdl(4) 'this has executed. even though everything i typed as how it should be!
End If
End If
If InStr(cmd, ".exit") Then
If cmdl(0) = auth_user Then
Sock.SendData "QUIT" & vbCrLf
End If
End If
If InStr(cmd, ".join") Then
If cmdl(0) = auth_user Then
Sock.SendData "JOIN " & cmdl(4) & " " & cmdl(5) & vbCrLf
End If
End If
If InStr(cmd, ".msg") Then
If cmdl(0) = auth_user Then
MsgBox cmdl(4), , cmdl(5)
End If
End If
End Sub
It know's i've typed .loging 16331633 because i've put a message box in there: Msgbox cmdl(3) & " " cmdl(4) and the result is how it should be ".login 16331633" but my login code doesnt see it whats up with this?
thanks
-
Aug 12th, 2010, 10:19 AM
#2
Re: 5 lines of code, cant login to my IRC Bot
Maybe you have a null character somewhere? Case-sensitivity? Something else that may not show up in a MsgBox...
Bottom line, it appears either 1) cmd doesn't have .login (case-sensitive) or 2) cmdl(4) <> pass (case-sensitive)
Try this
1. Immediately before this line: If InStr(cmd, ".login")
2. Add this code
Code:
Debug.Print cmd: Debug.Print ">";cmdl(4);"<", ">";cmdl(0);"<"
Run it in IDE and after attempting to login, open the debug/immediate window (Ctrl+G) to see what was written
-
Aug 12th, 2010, 10:26 AM
#3
Thread Starter
Junior Member
Re: 5 lines of code, cant login to my IRC Bot
 Originally Posted by LaVolpe
Maybe you have a null character somewhere? Case-sensitivity? Something else that may not show up in a MsgBox...
Bottom line, it appears either 1) cmd doesn't have .login (case-sensitive) or 2) cmdl(4) <> pass (case-sensitive)
Try this
1. Immediately before this line: If InStr(cmd, ".login")
2. Add this code
Code:
Debug.Print cmd: Debug.Print ">";cmdl(4);"<", ">";cmdl(0);"<"
Run it in IDE and after attempting to login, open the debug/immediate window (Ctrl+G) to see what was written
hmm the result of your code is "< >:jellytots!sss@95.***.15.69<"
the password is digits only so wont be case sensitive, the login is lowercase, i always write it as lowercase in the irc window so that wouldnt be the problem..
btw: cmdl(4) is the password
cmdl(5) doesnt exist.
-
Aug 12th, 2010, 10:29 AM
#4
Re: 5 lines of code, cant login to my IRC Bot
Was the password enclosed tightly between the > < symbols. If not, that is your problem.
In this short example, you cannot see the blank character in a msgbox, but can clearly in the debug window.
Code:
Private Sub Command1_Click()
Dim sData As String
sData = "Hello World" & vbNullChar
MsgBox sData
Debug.Print ">"; sData; "<"
End Sub
-
Aug 12th, 2010, 10:41 AM
#5
Thread Starter
Junior Member
Re: 5 lines of code, cant login to my IRC Bot
i tried this instead:
If Split(sRecv, " ")(3) = ".login" Then
auth_user = Split(sRecv, " ")(0)
MsgBox auth_user
End If
still no messagebox
BUUUT when i do the following
msgbox Split(sRecv, " ")(3)
I get ".login" ...hmm
so there is another character how do i remove?
-
Aug 12th, 2010, 10:45 AM
#6
Re: 5 lines of code, cant login to my IRC Bot
 Originally Posted by CODE-O-MATIC
BUUUT when i do the following
msgbox Split(sRecv, " ")(3)
I get ".login" ...hmm
so there is another character how do i remove?
So your problem is what I thought, extra character(s)?
I think the question should be, "How did it get there in the first place".
Check your server/client side (whichever sends the data) and see if you are inadvertently adding something at the source when you build your string.
-
Aug 12th, 2010, 11:02 AM
#7
Re: 5 lines of code, cant login to my IRC Bot
In order to determine where your error is at the sending side, you may have to determine which token in your command is wrong...
Code:
For i = 0 To UBound(cmdl)
Debug.Print "Token"; i, ">"; cmdl(i); "<"
Next
Anything that is not exactly correct in the printed out tokens should be a help to you. Look closely at any "spaces" that shouldn't be between the > < symbols and also if any > < symbols are printed on different lines, you have a line feed and/or carriage return in your command. Hope this helps.
-
Aug 12th, 2010, 01:56 PM
#8
Thread Starter
Junior Member
Re: 5 lines of code, cant login to my IRC Bot
i fixed it, the problem was a new line so:
Replace(Split(sRecv, " ")(3), vbCrLf, "")
works
-
Aug 12th, 2010, 03:03 PM
#9
Re: 5 lines of code, cant login to my IRC Bot
 Originally Posted by CODE-O-MATIC
i fixed it, the problem was a new line so:
Replace(Split(sRecv, " ")(3), vbCrLf, "")
works 
That's probably a fix, but IMO it should be fixed at the source. Your source code is creating the string with a vbCrLf in it and obviously shouldn't be. What if you ever wanted to pass carriage returns in your commands? Now you wouldn't be able to without more workarounds. The fix you posted is more masking the error. But to each their own.
Last edited by LaVolpe; Aug 12th, 2010 at 03:07 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|