nakiircbot 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nakiircbot.rb +18 -11
- data/nakiircbot.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a730c87c3b3d41670bf1a9b3be778c01ec4e92e66c996fc9673876b9ae3bced
|
4
|
+
data.tar.gz: b3aef7375122b38a2c352d746962b629200fe32d99648dd2d4ffe1e144a8d6e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e786766517a178e20a3de5eed2f1eeb51803eb9cc5b2bcfdf209a1de072509e57bad069289321f5a154fcf797483b2cca62ec8cff193b4697c41e7f741e2638c
|
7
|
+
data.tar.gz: 11ff7989502f426d5f3f8ba0fbe04d8f6dfad87b2fec57f8c991eece8be31a3c8b6496cc663f2105fe611ebff5ecb5a52782167cf63e751d2cd62db22bafe27d
|
data/lib/nakiircbot.rb
CHANGED
@@ -34,6 +34,7 @@ module NakiIRCBot
|
|
34
34
|
socket.send str + "\n", 0
|
35
35
|
end
|
36
36
|
# socket.send "PASS #{password.strip}\n", 0 if twitch
|
37
|
+
socket_send.call "CAP REQ :sasl"
|
37
38
|
socket_send.call "NICK #{bot_name}"
|
38
39
|
socket_send.call "USER #{bot_name} #{bot_name} #{bot_name} #{bot_name}" #unless twitch
|
39
40
|
|
@@ -42,23 +43,23 @@ module NakiIRCBot
|
|
42
43
|
loop do
|
43
44
|
begin
|
44
45
|
addr, msg = queue.shift
|
45
|
-
next unless addr && msg
|
46
|
+
next unless addr && msg # TODO: how is it possible to have only one of them?
|
46
47
|
addr = addr.codepoints.pack("U*")
|
47
48
|
fail "I should not PRIVMSG myself" if addr == bot_name
|
48
49
|
msg = msg.to_s.codepoints.pack("U*").chomp[/^(\x01*)(.*)/m,2].gsub("\x00", "[NUL]").gsub("\x0A", "[LF]").gsub("\x0D", "[CR]")
|
49
|
-
privmsg = "PRIVMSG #{addr} :#{msg}"
|
50
|
-
privmsg[-4..-1] = "..." until privmsg.bytesize <= 475
|
50
|
+
privmsg = "PRIVMSG #{addr} :#{msg}"
|
51
|
+
privmsg[-4..-1] = "..." until privmsg.bytesize <= 475
|
51
52
|
prev_socket_time = prev_privmsg_time = Time.now
|
52
53
|
socket_send.call privmsg
|
53
54
|
break
|
54
|
-
end until queue.empty? if prev_privmsg_time + 5 < Time.now
|
55
|
+
end until queue.empty? if prev_privmsg_time + 5 < Time.now || server == "localhost"
|
55
56
|
|
56
57
|
unless _ = Kernel::select([socket], nil, nil, 1)
|
57
58
|
break if Time.now - prev_socket_time > 300
|
58
59
|
next
|
59
60
|
end
|
60
61
|
prev_socket_time = Time.now
|
61
|
-
socket_str = _[0][0].gets
|
62
|
+
socket_str = _[0][0].gets chomp: true
|
62
63
|
break unless socket_str
|
63
64
|
str = socket_str.force_encoding("utf-8").scrub
|
64
65
|
if /\A:\S+ 372 /.match? str # MOTD
|
@@ -81,20 +82,26 @@ module NakiIRCBot
|
|
81
82
|
# we join only when we are sure we are on the correct server
|
82
83
|
# TODO: maybe abort if the server is wrong?
|
83
84
|
next socket_send.call "JOIN #{channels.join ","}"
|
85
|
+
|
84
86
|
when /\A:tmi.twitch.tv 001 #{Regexp.escape bot_name} :Welcome, GLHF!\z/
|
85
87
|
socket_send.call "JOIN #{channels.join ","}"
|
86
88
|
socket_send.call "CAP REQ :twitch.tv/membership twitch.tv/tags twitch.tv/commands"
|
87
89
|
next
|
88
|
-
when /\A:NickServ!NickServ@services\. NOTICE #{Regexp.escape bot_name} :This nickname is registered. Please choose a different nickname, or identify via \x02\/msg NickServ identify <password>\x02\.\z
|
90
|
+
when /\A:NickServ!NickServ@services\. NOTICE #{Regexp.escape bot_name} :This nickname is registered. Please choose a different nickname, or identify via \x02\/msg NickServ identify <password>\x02\.\z/,
|
91
|
+
/\A:NickServ!NickServ@services\.libera\.chat NOTICE #{Regexp.escape bot_name} :This nickname is registered. Please choose a different nickname, or identify via \x02\/msg NickServ IDENTIFY #{Regexp.escape bot_name} <password>\x02\z/
|
89
92
|
abort "no password" unless password
|
90
93
|
logger.info "password"
|
91
|
-
# next socket.send "PASS #{password.strip}\n", 0
|
92
94
|
next socket.send "PRIVMSG NickServ :identify #{bot_name} #{password.strip}\n", 0
|
93
|
-
#
|
94
|
-
|
95
|
-
|
95
|
+
# when /\A:[a-z]+\.libera\.chat CAP \* LS :/
|
96
|
+
# next socket_send "CAP REQ :sasl" if $'.split.include? "sasl"
|
97
|
+
when /\A:[a-z]+\.libera\.chat CAP \* ACK :sasl\z/
|
98
|
+
next socket_send.call "AUTHENTICATE PLAIN"
|
99
|
+
when /\AAUTHENTICATE \+\z/
|
96
100
|
logger.info "password"
|
97
|
-
next socket.send "
|
101
|
+
next socket.send "AUTHENTICATE #{Base64.strict_encode64 "#{bot_name}\0#{bot_name}\0#{password}"}\n", 0
|
102
|
+
when /\A:[a-z]+\.libera\.chat 903 #{bot_name} :SASL authentication successful\z/
|
103
|
+
next socket_send.call "CAP END"
|
104
|
+
|
98
105
|
when /\APING :/
|
99
106
|
next socket.send "PONG :#{$'}\n", 0 # Quakenet uses timestamp, Freenode and Twitch use server name
|
100
107
|
when /\A:([^!]+)!\S+ PRIVMSG #{Regexp.escape bot_name} :\x01VERSION\x01\z/
|
data/nakiircbot.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "nakiircbot"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.3"
|
4
4
|
spec.summary = "IRC bot framework"
|
5
5
|
|
6
6
|
spec.author = "Victor Maslov aka Nakilon"
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.license = "MIT"
|
9
9
|
spec.metadata = {"source_code_uri" => "https://github.com/nakilon/nakiircbot"}
|
10
10
|
|
11
|
-
spec.required_ruby_version = ">=2.5" # for Exception#full_message and block rescue
|
11
|
+
spec.required_ruby_version = ">=2.5" # at least for Exception#full_message and block rescue
|
12
12
|
|
13
13
|
spec.files = %w{ LICENSE nakiircbot.gemspec lib/nakiircbot.rb }
|
14
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nakiircbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov aka Nakilon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: nakilon@gmail.com
|