-
-
Save shurizzle/892172 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
# who the fuck said Ruby couldn't be hacky, NEVER DO THIS IT IS STUPID | |
# AND DOING IT WRONG TOO | |
require 'socket' | |
# DEBUG {{{ | |
class TCPSocket | |
alias __gets__ gets | |
def gets(*args) | |
$DEBUG ? [__gets__(*args)].each {|m| STDOUT.puts '<< ' + m }[0] : __gets__(*args) | |
end | |
alias __write__ write | |
def write(*args) | |
args.each {|m| STDOUT.puts '>> ' + m.to_s } if $DEBUG | |
__write__(*args) | |
end | |
end | |
# }}} | |
($s = TCPSocket.new(*ARGV[1, 2].map {|a| Integer(a) rescue a }) rescue nil) or puts("Usage: #$0 <nick> <server> <port>") or exit(1) | |
define_singleton_method(:w) {|*a| $s.write a.join("\r\n") + "\r\n"} && w("NICK #{ARGV[0]}", "USER #{ARGV[0]} 0 * :#{ARGV[0]}") | |
$s.gets[/PING :(.+)/] && w('PONG ' + $1) until $s.eof? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment