module Balotelli::Core::IRC
Public Instance Methods
configure(host, port, nick, pass = nil)
click to toggle source
# File lib/balotelli/core/irc.rb, line 6 def configure(host, port, nick, pass = nil) @host = host @port = port @nick = nick @pass = pass @socket = nil @mutex = Mutex.new end
connect(&block)
click to toggle source
# File lib/balotelli/core/irc.rb, line 16 def connect(&block) @socket = TCPSocket.new(@host, @port) sputs("PASS #{@pass}") if @pass sputs("NICK #{@nick}") sputs("USER #{@nick} 0 * :#{@nick}") instance_variable_set(:@on_connect, block) if block_given? end
join(channel, password = nil)
click to toggle source
# File lib/balotelli/core/irc.rb, line 47 def join(channel, password = nil) sputs("JOIN #{channel} #{password}") end
names(channel)
click to toggle source
# File lib/balotelli/core/irc.rb, line 55 def names(channel) sputs("NAMES #{channel}") end
pong(message)
click to toggle source
# File lib/balotelli/core/irc.rb, line 43 def pong(message) sputs("PONG #{message}") end
privmsg(channel, message)
click to toggle source
# File lib/balotelli/core/irc.rb, line 51 def privmsg(channel, message) sputs("PRIVMSG #{channel} :#{message}") end
sgets()
click to toggle source
# File lib/balotelli/core/irc.rb, line 26 def sgets str = @socket.gets str.chomp! unless str.nil? puts '<< ' + str.inspect str end
sputs(str)
click to toggle source
# File lib/balotelli/core/irc.rb, line 35 def sputs(str) @mutex.synchronize do puts '>> ' + str.inspect @socket.puts(str) end end