本文介绍了我的Ruby IRC机器人未连接到IRC服务器.我究竟做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
require "socket"
server = "irc.rizon.net"
port = "6667"
nick = "Ruby IRC Bot"
channel = "#0x40"
s = TCPSocket.open(server, port)
s.print("USER Testing", 0)
s.print("NICK #{nick}", 0)
s.print("JOIN #{channel}", 0)
此IRC机器人未连接到IRC服务器,我在做什么错了?
This IRC bot doesn't connect to the IRC server, What am I doing wrong?
推荐答案
失败,并显示以下消息:
It failed with this message:
:irc.shakeababy.net 461 * USER :Not enough parameters
因此更改您的代码.例如,此方法有效:
so change your code. For example, this one works:
require "socket"
server = "irc.rizon.net"
port = "6667"
nick = "Ruby IRC Bot"
channel = "#0x40"
s = TCPSocket.open(server, port)
print("addr: ", s.addr.join(":"), "\n")
print("peer: ", s.peeraddr.join(":"), "\n")
s.puts "USER testing 0 * Testing"
s.puts "NICK #{nick}"
s.puts "JOIN #{channel}"
s.puts "PRIVMSG #{channel} :Hello from IRB Bot"
until s.eof? do
msg = s.gets
puts msg
end
有关USER的更多信息,请参见 http://en.wikipedia.org/wiki/List_of_Internet_Relay_Chat_commands#USER
For more information about USER, see http://en.wikipedia.org/wiki/List_of_Internet_Relay_Chat_commands#USER
这篇关于我的Ruby IRC机器人未连接到IRC服务器.我究竟做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!