class RbIRC

Public Class Methods

start(server, nick, channel) click to toggle source

The main class

Example

>>RbIRC.start("irc.rizon.net", "MyNick", "#YourFavouriteChannel")
It should connect after that and will start showing essentially raw IRC
# File lib/rbirc.rb, line 8
def self.start(server, nick, channel)
        puts "Starting connect to #{server} with nick #{nick}"
        sock = TCPSocket.new(server, 6667)
        while stuff = sock.gets
        if stuff.include? "Couldn't"
                sock.puts "USER #{nick} #{nick} #{nick} :#{nick}\r\n", 'UTF-8'
                sock.puts "NICK #{nick}\r\n" , 'UTF-8'
                sock.puts "JOIN #{channel}\r\n"
        end
        puts stuff
        end                   
        while line = sock.gets
                if  line.include? "PING"     
                        ping = Array.new
                        ping = line.split(':')
                        sock.puts "PONG : #{ping[1]}\r\n"
                end                          
        end           
        
end