print "ruby irc bot\nbrought to you by novatech\nhttp://wan.pengganas.net" require 'socket' server = "java.webchat.org" port = "6667" bot = TCPSocket.open(server,port) bot.send("USER novaBot novaBot novaBot :Written in Ruby ;)\r\n",0) bot.send("NICK botcapayam\r\nJOIN #maher\r\n", 0) stay = 1 while stay == 1 str = String.new(bot.readline) #i don't know why i did this -_-" #check if we have ping if /^PING :(.*)/.match(str) bot.send("PONG #$1\r\n", 0) end if /^:novatech!(.*)@(.*) PRIVMSG #(.*) :(.*)/.match(str) command = "#$3 #$4" bot.send("PRIVMSG ##$1 #$2\r\n", 0) if command =~ /(.*) ~say (.*)/ bot.send("PRIVMSG #$2\r\n", 0) if command =~ /(.*) ~msg (.*)/ bot.send("JOIN ##$2\r\n", 0) if command =~ /(.*) ~join (.*)/ bot.send("PART ##$2\r\n", 0) if command =~ /(.*) ~part (.*)/ stay = 0 if command =~ /(.*) ~quit/ end if /^:(.*)!(.*)@(.*) PRIVMSG #(.*) :(askum|assalamualaikum|akum|a'kum)/.match(str) bot.send("PRIVMSG ##$4 wa'alaikumussalam #$1\r\n", 0) end #puts bot.readline // for debug purpose end #end while bot.close