开发者

Getting User Count From IRC

I am making IRC chat client and I am wanting to grab the user list or simply the user count, how can I go about doing this. This is the method I'm using to connect to the IRC:

Private Sub IRCConnect()
        Dim stream As NetworkStream
        Dim irc As TcpClient
        Dim reader As StreamReader
        Try
            irc = New TcpClient(SERVER, PORT)
          开发者_如何学Go  stream = irc.GetStream()
            reader = New StreamReader(stream)
            writer = New StreamWriter(stream)
            ' Start PingSender thread
            Dim ping As New PingSender
            ping.Start()
            writer.WriteLine(USER)
            writer.Flush()
            writer.WriteLine("NICK " & Config.Nickname)
            writer.Flush()
            writer.WriteLine("JOIN " & Config.Channel & " " & Config.ChanPass)
            writer.Flush()
            txtView.Text = txtView.Text & ">Connected successfully." & vbNewLine
            HighlightPhrase(txtView, "Connected successfully.", Color.Lime)
            Thread.Sleep(2000)
        Catch Ex As Exception
            ' Show the exception, sleep for a while and try to establish a new connection to irc server
            txtView.Text = txtView.Text & ">ERROR: Unexpected error occured: " & Ex.ToString & vbNewLine
            HighlightPhrase(txtView, "Unexpected error occured: " & Ex.ToString, Color.Red)
        End Try
    End Sub

I have no idea where to start, any help would be much appreciated.


The IRC-protocol is defined in RFC2812: https://www.rfc-editor.org/rfc/rfc2812

Send the "NAMES #currentchannel" - command ( https://www.rfc-editor.org/rfc/rfc2812#section-3.2.5 ) and you will receive a list of all visible users. This list can be counted and voilà - there you got your user-count


Start by reading the the specification for IRC, it is RFC 2812.

You'll want to use the NAMES message. Here is the appropriate section from the RFC.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜