Created
May 21, 2011 05:01
-
-
Save ukstudio/984268 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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