cibot/src/cibot.cr

30 lines
551 B
Crystal

require "socket"
SERVER = "iiiypuk.me"
PORT = 6667
NICK = "crystal"
CHANNEL = "#admin"
puts "Connecting..."
irc = TCPSocket.new(SERVER, PORT)
irc << "USER #{NICK} . . :This is a bot!\n"
irc << "NICK #{NICK}\r\n"
irc << "JOIN #{CHANNEL}\r\n"
irc << "PRIVMSG #{CHANNEL} :!time\r\n"
while true
response = irc.gets
puts response
if response.to_s.includes?("PING")
irc << "PONG #{response.to_s.split[1]}\r\n"
end
if response.to_s.includes?("!time")
irc << "PRIVMSG #{CHANNEL} :#{Time.local.to_unix}\r\n"
end
end
irc.close