My Ruby IRC bot doesn't connect to the IRC server. What am I doing wrong?

require "socket"

server = ""
port = "6667"
nick = "Ruby IRC Bot"
channel = "#0x40"

s =, port)
s.print("USER Testing", 0)
s.print("NICK #{nick}", 0)
s.print("JOIN #{channel}", 0)

This IRC bot doesn't connect to the IRC server, What am I doing wrong?


It failed with this message: 461 * USER :Not enough parameters

so change your code. For example, this one works:

require "socket"

server = ""
port = "6667"
nick = "Ruby IRC Bot"
channel = "#0x40"

s =, 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

For more information about USER, see

I wrote a tiny IRC bot framework you may wish to use (as a reference):

The "USER" input is formed like:

"USER misc misc misc :misc\r\n"


s.print("USER #{nick} #{nick} #{nick} :#{nick}\r\n", 0)

should work. There are other ways to do it, but this is the quickest way I could come up with.

Need Your Help

What is the better Way to Store fixed no of data in Java? (Array vs ArrayList)


I believe Array and ArrayList both are non-Synchronised;behave same in multiThreaded env.

Dependency Analysis Code Error / CodeSign error

ios iphone xcode ipad

I'm going to get this out of my system before continuing so that you can see my dilema.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.