IRC bot
This commit is contained in:
parent
181633e610
commit
5fedd53075
@ -5,3 +5,6 @@
|
||||
- [IO::TimeoutError](prompt_timeout.cr) - Установка тайм-аута на пользовательский ввод
|
||||
- [ENV["..."]](env_variable.cr) - Переменные среды
|
||||
- [Colorize](Colorize.cr) - Цветной вывод в консоль
|
||||
|
||||
## Stuff
|
||||
- [`irc_bot.cr`](irc_bot.cr) - Реализация клиента (бота) для IRC
|
||||
|
24
~/Crystal/irc_bot.cr
Normal file
24
~/Crystal/irc_bot.cr
Normal file
@ -0,0 +1,24 @@
|
||||
require "socket"
|
||||
|
||||
puts "Connecting..."
|
||||
irc = TCPSocket.new("iiiypuk.me", 6667)
|
||||
|
||||
irc << "USER crystal localhost localhost :This is a bot!\n"
|
||||
irc << "NICK crystal\r\n"
|
||||
irc << "JOIN #admin\r\n"
|
||||
irc << "PRIVMSG #admin :!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 #admin :#{Time.local.to_unix}\r\n"
|
||||
end
|
||||
end
|
||||
|
||||
irc.close
|
Loading…
Reference in New Issue
Block a user