Results 1 to 9 of 9

Thread: 5 lines of code, cant login to my IRC Bot

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    27

    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

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    27

    Re: 5 lines of code, cant login to my IRC Bot

    Quote Originally Posted by LaVolpe View Post
    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.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    27

    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?

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: 5 lines of code, cant login to my IRC Bot

    Quote Originally Posted by CODE-O-MATIC View Post
    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    27

    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

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: 5 lines of code, cant login to my IRC Bot

    Quote Originally Posted by CODE-O-MATIC View Post
    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width