Results 1 to 26 of 26

Thread: IRC Client How To Get Channel Text Help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    IRC Client How To Get Channel Text Help

    I have the client its in vb.net 8 i am using Microsoft Visual Studio 2005 it can connect and disconnect from the server join and leave the channel and can send text to the channel and it tells me what i say when i leave and join and connect and disconnect but i cant get it to get the text that everyone else says i used a tutorial and some of another guys source that he posted and i am wondering how i can make it get the data of what people say and have it output it to my status window i can send the source to someone if they need thank you and sry for not putting this into sentences i am kind of in a rush :P
    edit: I am using winsocks and i thought this would work but it dosent

    Code:
            Dim data As String
    
            Winsock1.GetData(data)
            txtstatus.Text = txtstatus.Text & data & vbCrLf
    Last edited by zillarat; Aug 26th, 2007 at 09:53 PM.

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: IRC Client How To Get Channel Text Help

    Welcome to the Forum :-)

    In what event-routine did you put the code posted?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    thank you and event-routine?

  4. #4
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: IRC Client How To Get Channel Text Help

    You did post some code, in what Sub did you place this code (for example: Private Sub WinSock1_DataArrival)
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    Ah yes DataArrival

    Code:
        Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
            Dim data As String
    
            Winsock1.GetData(data, vbString, bytesTotal)
            txtstatus.Text = txtstatus.Text & data & vbCrLf
    
            If InStr(data, "PING") = 1 Then
                Winsock1.SendData("PONG " & Split(data, " ")(1))
            End If
    
        End Sub

  6. #6
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: IRC Client How To Get Channel Text Help

    Try to place a breakpoint in this sub and see if it this breakpoint fires. If not it looks like you are not really connected!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    ok i did it and there is nothing in the immediate window also no hits but i am connected because i can see my client nick and it can send text into the channel can i see it.
    It wont get the data so i dont know what to do... :/
    Last edited by zillarat; Aug 27th, 2007 at 04:45 AM.

  8. #8
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: IRC Client How To Get Channel Text Help

    How do you "see" the client nick?
    Are "you" also a client?
    When you send text to the "channel", where does it go (to the server, the a client..., is it recieved by anybody?)
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    The client i made connects to an IRC server but I also have the MIRC client connected to the same server in a channel I have that my IRC client I made will go in, when i connect the client i made and join the channel, i go to my MIRC client and i can see the client i made also i use the text box im the client i made and i can send messages to the channel and i can see them with both clients but when i send messages to the channel with mirc i cant see them in my client i made

  10. #10
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: IRC Client How To Get Channel Text Help

    So you can send messages using your VB-project, but you can't recieve messages, is that correct?
    I don't know how those IRC and MIRC do send, maybe they use a kind of broadcast to send the messages recieved by the server to the connected clients?
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    Yes your first part is correct i cannot receive messages.
    but i can send them with basicly this code
    Code:
    Winsock1.SendData("PRIVMSG #" + jchannel + " :" + Trim(txtsend.Text) & vbCrLf)
    PRIVMSG is how u can also send messages to people but u can just make it send to the channel with the # witch is what i have done

  12. #12
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: IRC Client How To Get Channel Text Help

    I think you are sending those messages to the server, and the server does retranmit them to the clients that are addressed (either all on the channel or a single one). That maybe a different winsock, and for that reason you don't get the messages. But I only think it is this reason, to know it is a differetn thing!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    so what do i have to do? I am looking through this and its like the sub Winsock1_DataArrival dosent exist or it dosent read it or something how can i make the priject know its there?
    Last edited by zillarat; Aug 27th, 2007 at 04:50 PM.

  14. #14
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: IRC Client How To Get Channel Text Help

    If my assumption was correct (..that the server does send the messages on a different connection), your Winsock1 will NOT get any message, and the .DataArrival event will not fire at all!
    To know that you have to look at what the server doing!!
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  15. #15
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: IRC Client How To Get Channel Text Help

    When connecting to an IRC channel you'll have to parse raw data. Here's a basic example.
    Attached Files Attached Files

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    Opus so wouldent the server atleast send something or do i have to put a code in to tell the server to send me something?
    Chris thanks for the code i dont see in it how the server send me anything i do everything in that and more alos i looked at the Winsock_DataArrival and i used some of that if thats ok but i cant even test it because my Winsock1_DataArrival dosent even get hit so first have to get that working :/

  17. #17
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: IRC Client How To Get Channel Text Help

    You don't have to tell the server to send you something. As soon as you connect to the IRC server it starts sending you information about the server.

    Do you have "Option Explicit" at the top of your forms/modules/classes to check if you've made any mistakes? Maybe you've made a typo and without "Option Explicit" those small mistakes are hardly noticed.


    ::Edit::

    And what port number are you using? Port number '6667' must be used or you won't be able to connect.
    Last edited by Chris001; Aug 28th, 2007 at 09:06 PM.

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    yes i have it on i could just post the whole source if u guys want cuse im outa ideas on how to fix this, i cant find any errors, and all my friends that program program in c++ and they say learn c++
    edit: yes its port 6667 i can connect to the server and talk in the channels i just cant receive anything.

  19. #19
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: IRC Client How To Get Channel Text Help

    Yes, posting your code would be the best.

  20. #20

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    lol k

    Code:
    Option Explicit On
    Public Class main
    
        Dim jchannel
        Dim inick
        Dim ihost
        Dim iport
    
        Private Sub txtsend_GotFocus()
    
        End Sub
    
        Private Sub connect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles connect.Click
            inick = txtNick.Text
            ihost = txtHost.Text
            iport = txtPort.Text
            Winsock1.Close()
            Winsock1.RemotePort = iport
            Winsock1.RemoteHost = ihost
            Winsock1.Connect()
            txtstatus.Text = txtstatus.Text & "Connected To " + ihost + "" & vbNewLine
        End Sub
    
    
        Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
            Dim strData As String, arrData() As String, i As Long
            Dim arrWords() As String, arrParms() As String
            Dim x As Long, y As Long, sName As String
    
            Winsock1.GetData(strData)
    
            txtstatus.Text = txtstatus.Text & strData & vbCrLf
    
            'Seperate the different lines of data and parse through them
            arrData = Split(strData, vbCrLf)
            For i = 0 To UBound(arrData) - 1
                arrWords = Split(arrData(i), " ")
                arrParms = Split(arrData(i), ":")
                'Get the seperate pieces of data that may be needed.
                'Then Parse the data.
                Select Case UCase$(arrWords(1))
                    Case "PRIVMSG"
                        'Get the name of the user who typed the message
                        x = InStr(arrParms(1), "!~")
                        If x Then
                            sName = Mid$(arrParms(1), 1, x - 1)
                        End If
                        txtstatus.Text = txtstatus.Text & "<" & sName & "> " & arrParms(2) & vbCrLf
                    Case Else
                        'Check for a PING and reply to it
                        If UCase$(arrWords(0)) = "PING" Then
                            Winsock1.SendData("PONG :" & arrParms(1) & vbCrLf)
                        End If
                End Select
            Next i
    
        End Sub
    
    
        Private Sub disconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles disconnect.Click
    
            Winsock1.SendData("QUIT" & vbCrLf)
            txtstatus.Text = txtstatus.Text & "Disconnected From " + ihost + "" & vbNewLine
            Winsock1.Close()
        End Sub
    
        Private Sub join_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles join.Click
            jchannel = txtJoin.Text
            Winsock1.SendData("JOIN #" + jchannel & vbCrLf)
            txtstatus.Text = txtstatus.Text & "Now Talking In " + jchannel + "" & vbNewLine
        End Sub
    
        Private Sub part_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles part.Click
            jchannel = txtJoin.Text
            Winsock1.SendData("PART #" + jchannel & vbCrLf)
            txtstatus.Text = txtstatus.Text & "You Left " + jchannel + "" & vbNewLine
        End Sub
    
        Private Sub txtsend_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsend.TextChanged, sendbutton.TextChanged
    
        End Sub
    
        Private Sub Winsock1_ConnectEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Winsock1.ConnectEvent
            Winsock1.SendData("NICK " + inick & vbCrLf)
            Winsock1.SendData("USER " + inick + " " + inick + " " + inick + " " + inick + " " + inick & vbCrLf)
        End Sub
    
        Private Sub send_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sendbutton.Click
    
            If Trim(txtsend.Text) = "" Then Exit Sub
            Winsock1.SendData("PRIVMSG #" + jchannel + " :" + Trim(txtsend.Text) & vbCrLf)
            txtstatus.Text = txtstatus.Text & "<" + inick + "> " + Trim(txtsend.Text) & vbNewLine
            txtsend.Text = ""
            txtsend.Focus()
        End Sub
        Private Sub txtNick_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNick.TextChanged
    
        End Sub
    
        Private Sub txtHost_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtHost.TextChanged
    
        End Sub
    
        Private Sub txtPort_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPort.TextChanged
    
        End Sub
    
        Private Sub txtJoin_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtJoin.TextChanged
    
        End Sub
        Private Sub txtstatus_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtstatus.TextChanged
    
        End Sub
    
        Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
    
        End Sub
    
        Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
    
        End Sub
    
        Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
    
        End Sub
    
        Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    
        End Sub
    
        Private Sub main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    
        End Sub
    End Class
    Last edited by zillarat; Aug 28th, 2007 at 09:29 PM.

  21. #21
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: IRC Client How To Get Channel Text Help

    Are you using vb.net?
    The code you posted earlier is vb6, so I assumed you were using that.

    If you're using vb.net, then unfortunately I won't be able to help you, because I don't know any .net.

  22. #22

    Thread Starter
    Junior Member
    Join Date
    Aug 2007
    Location
    http://ZeroMeaning.com
    Posts
    16

    Re: IRC Client How To Get Channel Text Help

    yeah is vb.net :/

  23. #23
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: IRC Client How To Get Channel Text Help

    There are a few things to take into account. First of all, buffering: you might not always get a full line at once when you receive data, so you can only rely a full line is submitted if the last array element is empty (when you've splitted by line change). So, you need to keep the last array item in memory, and combine it to the first one:

    Code:
    Static Buffer As String
    
    ' ...
    arrData = Split(strData, vbCrLf)
    arrData(0) = Buffer & arrData(0)
    
    ' ...
    
    Buffer = arrData(UBound(arrData))
    So you might've been losing some information because of this.


    The other thing is that you should look for the first " :" only and split on that to separate message content from commands and parameters. Then you can parse the commands and parameters by space character.


    And third thing that comes to my mind is that you're relying on always receiving CRLF. However, some servers work a bit differently to the others and might use different line change:

    Code:
    ' convert all possible line changes to vbLf
    strData = Replace(strData, vbCrLf, vbLf)
    strData = Replace(strData, vbCr, vbLf)
    
    ' ... or the same on one line:
    strData = Replace(Replace(strData, vbCrLf, vbLf), vbCr, vbLf)
    And note: I'm also not familiar with .NET.

  24. #24
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: IRC Client How To Get Channel Text Help

    you can't just use a winsock like that in .NET , you should be using System.Net.Sockets.
    however if you wish to receive data in the data_arrival sub, you need to specify bytes not a string ( eg: a byte array ) also replace any Long's with Integer's
    so i'd try...
    Code:
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Integer)
        Dim bytesData(1024) As Byte
        Winsock1.GetData(bytesData)
        '/// get the data from the bytes() into a string ...
        Dim strData As String = System.Text.Encoding.ASCII.GetString(bytesData, 0, bytesTotal)
        '/// rest of your code here.
    
    End Sub
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  25. #25
    New Member
    Join Date
    Sep 2007
    Posts
    9

    Re: IRC Client How To Get Channel Text Help

    hi can u tell me about modem connection?

  26. #26
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: IRC Client How To Get Channel Text Help

    Quote Originally Posted by mitforyou
    hi can u tell me about modem connection?
    What do you mean by "modem connection" and how does this relate to an IRC Client?

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