从 IRC 获取用户计数

发布于 2024-09-08 08:11:12 字数 1376 浏览 6 评论 0原文

我正在制作 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

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

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)
            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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溺渁∝ 2024-09-15 08:11:12

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

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

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

素染倾城色 2024-09-15 08:11:12

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文