从 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
我不知道从哪里开始,任何帮助将不胜感激。
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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
首先阅读 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.