Simple socketing

K

Knut Mathiesen

Hi there, I recently started with Ruby and I am trying to make a very
simple irc bot, but I am having some slight problems though.

This is what I came up with:

require 'socket'
class Irc
def connect(server, port = 6667)
@socket = TCPsocket.new(server, port)
end
def to_server(text)
@socket.gets(text)
return true
end
def from_server()
return @socket.puts
end
end
irc = Irc.new
irc.connect("irc.homelien.no", 6667)
irc.to_server('NICK: testbot')
irc.to_server('USER: testbot "" "irc.efnet.net" :testbot')
go = true
while go == true
if (text = irc.from_server)
puts(text)
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,222
Latest member
patricajohnson51

Latest Threads

Top