nakiircbot 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/nakiircbot.rb +9 -10
- data/nakiircbot.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 48ee5e5b5a294eb86f735eddd3f8fe9e556dc8b630e77f03cc7b3be118f01d69
|
4
|
+
data.tar.gz: 2ee18ee0686a4a53a777f107846b538860d330b495c5294f1e0efd0612c1dbaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf6b65b35360cb21889ef9969a2f166ad3e928a20ca128970b0b49734fd3a547a412f87280b112e675014a97bd906c7f7f6a0df3b9429ff6c0397f544400f5f
|
7
|
+
data.tar.gz: fe10d2e4c2966e00242f9f17b6fae3342250da520074afb6e5871d0f2d02c5a2aa8030197765855899d264d2bfdfd42950960b62dfac3fab25a5884fca9d7561
|
data/lib/nakiircbot.rb
CHANGED
@@ -3,7 +3,7 @@ module NakiIRCBot
|
|
3
3
|
# class << self
|
4
4
|
# attr_accessor :channels
|
5
5
|
# end
|
6
|
-
def self.start server, port, bot_name, master_name, welcome001, *channels, password: nil, masterword: nil, processors: [],
|
6
|
+
def self.start server, port, bot_name, master_name, welcome001, *channels, password: nil, masterword: nil, processors: [], tags: false
|
7
7
|
# @@channels.replace channels.dup
|
8
8
|
|
9
9
|
abort "matching bot_name and master_name may cause infinite recursion" if bot_name == master_name
|
@@ -33,9 +33,9 @@ module NakiIRCBot
|
|
33
33
|
logger.info "> #{str}"
|
34
34
|
socket.send str + "\n", 0
|
35
35
|
end
|
36
|
-
socket.send "PASS #{password.strip}\n", 0 if twitch
|
36
|
+
# socket.send "PASS #{password.strip}\n", 0 if twitch
|
37
37
|
socket_send.call "NICK #{bot_name}"
|
38
|
-
socket_send.call "USER #{bot_name} #{bot_name} #{bot_name} #{bot_name}" unless twitch
|
38
|
+
socket_send.call "USER #{bot_name} #{bot_name} #{bot_name} #{bot_name}" #unless twitch
|
39
39
|
|
40
40
|
queue = []
|
41
41
|
prev_socket_time = prev_privmsg_time = Time.now
|
@@ -43,12 +43,11 @@ module NakiIRCBot
|
|
43
43
|
begin
|
44
44
|
addr, msg = queue.shift
|
45
45
|
next unless addr && msg
|
46
|
+
addr = addr.codepoints.pack("U*")
|
46
47
|
fail "I should not PRIVMSG myself" if addr == bot_name
|
47
|
-
msg.
|
48
|
-
|
49
|
-
|
50
|
-
privmsg = "PRIVMSG #{addr} :#{msg}"
|
51
|
-
privmsg = "PRIVMSG #{addr} :*flood*" if privmsg.bytes.size > 500 && addr.start_with?("#")
|
48
|
+
msg = msg.to_s.codepoints.pack("U*").chomp[/[^\x01].*/m].gsub("\x00", "[NUL]").gsub("\x0A", "[LF]").gsub("\x0D", "[CR]")
|
49
|
+
privmsg = "PRIVMSG #{addr} :#{msg}"[0,513]
|
50
|
+
privmsg[-4..-1] = "..." until privmsg.bytesize <= 475 # Libera in fact cuts last ~31 bytes
|
52
51
|
prev_socket_time = prev_privmsg_time = Time.now
|
53
52
|
socket_send.call privmsg
|
54
53
|
break
|
@@ -104,7 +103,7 @@ module NakiIRCBot
|
|
104
103
|
# socket_send.call "NOTICE",$1,"\001PING #{rand 10000000000}\001"
|
105
104
|
# when /^:([^!]+)!\S+ PRIVMSG #{Regexp.escape bot_name} :\001TIME\001$/
|
106
105
|
# socket_send.call "NOTICE",$1,"\001TIME 6:06:06, 6 Jun 06\001"
|
107
|
-
when /\A#{'\S+ ' if
|
106
|
+
when /\A#{'\S+ ' if tags}:(?<who>[^!]+)!\S+ PRIVMSG (?<where>\S+) :(?<what>.+)/
|
108
107
|
next( if processors.empty?
|
109
108
|
queue.push [master_name, "nothing to reload"]
|
110
109
|
else
|
@@ -112,7 +111,7 @@ module NakiIRCBot
|
|
112
111
|
queue.push [master_name, "reloading #{processor}"]
|
113
112
|
load File.absolute_path processor
|
114
113
|
end
|
115
|
-
end ) if $~.named_captures == {"who"=>master_name, "where"=>bot_name, "what"=>"#{
|
114
|
+
end ) if $~.named_captures == {"who"=>master_name, "where"=>bot_name, "what"=>"#{masterword.strip} reload"}
|
116
115
|
end
|
117
116
|
|
118
117
|
begin
|
data/nakiircbot.gemspec
CHANGED
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.0
|
4
|
+
version: 0.1.0
|
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-05
|
11
|
+
date: 2021-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: nakilon@gmail.com
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.
|
43
|
+
rubygems_version: 2.7.6.2
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: IRC bot framework
|