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