#!/usr/bin/ruby -w
require 'socket'
@irc = TCPSocket.new('collective.2600.net', 6668)
def write(p)
@irc.puts "#{p}\r\n"
end
write("NICK kix")
write("USER kix kix kix :kix kix")
while line = @irc.gets
puts line
#splits PRIVMSG line
if line =~ /^:(.+?)!(.+?)@(.+?)\sPRIVMSG\s(.+?):(.*)$/
nickname, name, host, channel, message = $1, $2, $3, $4, $5
end
#splits COMMAND line
if message =~ /\.(.+?)\s(.+)/
command, messageaftercommand = $1, $2
end
write("PONG #{$1}") if line =~ /^PING (.+)/
write("JOIN #c0re") if line =~ /MOTD/
#if admin commands
if nickname == "Blazin"
write("QUIT :bi") if command =~ /quit/
write("#{messageaftercommand}") if command =~ /raw/
end
#if commands
write("PRIVMSG #{channel} :#{messageaftercommand}") if command =~/say/
if command =~/math/
math = messageaftercommand
begin
answer = eval(math)
rescue => e
write("PRIVMSG #{channel} :#{e}")
else
write("PRIVMSG #{channel} :#{answer}")
end
end
end