vb.net - 从 IRC 获取用户计数

标签 vb.net list count irc

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

我不知道从哪里开始,非常感谢任何帮助。

最佳答案

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

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

关于vb.net - 从 IRC 获取用户计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3204175/

相关文章:

mysql - 如何获取自本月初以来添加的记录数

c# - VB.Net(8) 中的空合并运算符

vb.net - AxAcroPdf 加载后,执行某些操作

list - 如何删除序言中的子列表?

python - 带有键列表的快速字典填充

Python 用逗号连接字符串列表,但有一些条件 - 代码重构

MySQL 对元素进行分组并计算每组中的元素数

vb.net - 函数不会在所有代码路径上返回值。使用结果时,可能会在运行时发生空引用异常

c# - 支持.Net Framework4.0的Eclipse IDE、C#和VB.Net插件

mysql - SQL - 如何返回 0 的计数