commit 56f3239c7d12103d6864443afc4ab364b77c8ad1 Author: Alexander Popov Date: Sat Dec 31 00:26:30 2022 +0300 init diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fddf785 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[{*.cr,shard.yml}] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..3dbbd29 --- /dev/null +++ b/shard.yml @@ -0,0 +1,14 @@ +name: irc-cr +version: 0.1.0 + +authors: + - Alexander Popov + +description: | + Simple IRC bot + +targets: + irc-cr: + main: src/irc.cr + +license: Unlicense diff --git a/src/irc.cr b/src/irc.cr new file mode 100644 index 0000000..e0c9495 --- /dev/null +++ b/src/irc.cr @@ -0,0 +1,22 @@ +require "socket" + +SERVER = "iiiypuk.me" +PORT = 6667 +NICK = "irc-cr" +USER = "Axel" + +puts "Running..." +irc = TCPSocket.new(SERVER, PORT) + +irc << "USER #{NICK} . . :This is a bot!\n" +irc << "NICK #{NICK}\r\n" +irc << "PRIVMSG #{USER} :!time\r\n" + +while response = irc.gets + if response.to_s.includes?("PING") + irc << "PONG #{response.to_s.split[1]}\r\n" + end +end + +irc << "QUIT\r\n" +irc.close