2

我正在制作 IRC 聊天客户端,我想获取用户列表或只是用户数量,我该怎么做。这是我用来连接 IRC 的方法:

Private Sub IRCConnect()
        Dim stream As NetworkStream
        Dim irc As TcpClient
        Dim reader As StreamReader
        Try
            irc = New TcpClient(SERVER, PORT)
            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

我不知道从哪里开始,任何帮助将不胜感激。

4

2 回答 2

5

IRC 协议在 RFC2812 中定义:https ://www.rfc-editor.org/rfc/rfc2812

发送“NAMES #currentchannel” - 命令(https://www.rfc-editor.org/rfc/rfc2812#section-3.2.5),您将收到所有可见用户的列表。可以计算此列表并瞧瞧-您的用户数到了

于 2010-07-08T13:47:53.073 回答
1

首先阅读 IRC 的规范,它是 RFC 2812

您将需要使用 NAMES 消息。这是 RFC 中的相应部分

于 2010-07-08T13:49:06.673 回答