Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created May 21, 2011 05:01
Show Gist options
  • Save ukstudio/984268 to your computer and use it in GitHub Desktop.
Save ukstudio/984268 to your computer and use it in GitHub Desktop.
require 'socket'
class RubyIrcClient
def initialize(server = 'irc.freenode.net', port = 6667)
@server = server
@port = port
@socket= TCPSocket.new(@server, @port)
end
def login
nick('ukstudio_test').
user("ukstudio_test #{@server} #{@server} :Akamatsu Yuki").
join('#ukstudio')
end
def read
@socket.gets
end
def command(command, params)
send_message = command + ' ' + params + "\r\n"
p "sending... '#{send_message}'"
@socket.write(send_message)
end
def method_missing(method, *args)
command method.to_s, args.first
return self
end
end
## example
# client.login
# client.privmsg('hello,world')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment