This commit is contained in:
Alexander Popov 2022-09-24 22:07:08 +03:00
commit ffab8f9a14
Signed by: iiiypuk
GPG Key ID: D8C9B59A9F04A70C
6 changed files with 80 additions and 0 deletions

16
.editorconfig Normal file
View File

@ -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

0
.gitignore vendored Normal file
View File

11
HISTORY.md Normal file
View File

@ -0,0 +1,11 @@
## Legend
- 🐛 - Bug
- ✔️ - Fixed
- ❌ - Removed
- - Added
- - Information
- ♻️ - Edited
## 0.1.0 - [00/09/2022]
- -

10
README.md Normal file
View File

@ -0,0 +1,10 @@
cibot
=====
Build from source
-----------------
```
git clone ...
shards build --release
```

14
shard.yml Normal file
View File

@ -0,0 +1,14 @@
name: cibot
version: 0.1.0
authors:
- Alexander Popov <iiiypuk@fastmail.fm>
description: |
cibot is simple IRC bot
targets:
cibot:
main: src/cibot.cr
license: MIT

29
src/cibot.cr Normal file
View File

@ -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