commit ffab8f9a1427a0431c2d0d3861024cd546cc2626 Author: Alexander Popov Date: Sat Sep 24 22:07:08 2022 +0300 :) 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..e69de29 diff --git a/HISTORY.md b/HISTORY.md new file mode 100644 index 0000000..6172da3 --- /dev/null +++ b/HISTORY.md @@ -0,0 +1,11 @@ +## Legend +- 🐛 - Bug +- ✔ī¸ - Fixed +- ❌ - Removed +- ➕ - Added +- ℹī¸ - Information +- â™ģī¸ - Edited + +## 0.1.0 - [00/09/2022] +- ➕ - + diff --git a/README.md b/README.md new file mode 100644 index 0000000..9f4d21a --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +cibot +===== + +Build from source +----------------- + +``` +git clone ... +shards build --release +``` diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..977ecb3 --- /dev/null +++ b/shard.yml @@ -0,0 +1,14 @@ +name: cibot +version: 0.1.0 + +authors: + - Alexander Popov + +description: | + cibot is simple IRC bot + +targets: + cibot: + main: src/cibot.cr + +license: MIT diff --git a/src/cibot.cr b/src/cibot.cr new file mode 100644 index 0000000..0341864 --- /dev/null +++ b/src/cibot.cr @@ -0,0 +1,29 @@ +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