nakiircbot 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +5 -5
  2. data/lib/nakiircbot.rb +9 -10
  3. data/nakiircbot.gemspec +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d8ca18800562c7c0fd329e997bee46f5b27d8dba
4
- data.tar.gz: 20fa8cd1ceab4294bd91178fe65ebde49618d7ac
2
+ SHA256:
3
+ metadata.gz: 48ee5e5b5a294eb86f735eddd3f8fe9e556dc8b630e77f03cc7b3be118f01d69
4
+ data.tar.gz: 2ee18ee0686a4a53a777f107846b538860d330b495c5294f1e0efd0612c1dbaa
5
5
  SHA512:
6
- metadata.gz: aeb84857a8086ec6cf62cc907968820aff82513b0795793c49b73567f47a18243a10130584e02086f34af04a35cfbe00c812f976e6d641db1779a090ada1a4d1
7
- data.tar.gz: '0081fc35339b93b87d2e08dd0b6ee5855df5675fc44fa3b8c9d33a0c8bdbfc5a9808225162aa1b3f3864e1adb61ca616984ff7fe97807877b7b2e7c1896ab2be'
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: [], twitch: false
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.scrub!
48
- msg.gsub! "\n", " "
49
- msg.gsub! "\r", " "
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 twitch}:(?<who>[^!]+)!\S+ PRIVMSG (?<where>\S+) :(?<what>.+)/
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"=>"#{twitch ? "@#{bot_name} " : "#{masterword.strip} "}reload"}
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "nakiircbot"
3
- spec.version = "0.0.2"
3
+ spec.version = "0.1.0"
4
4
  spec.summary = "IRC bot framework"
5
5
 
6
6
  spec.author = "Victor Maslov aka Nakilon"
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.2
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-20 00:00:00.000000000 Z
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.5.2.3
43
+ rubygems_version: 2.7.6.2
44
44
  signing_key:
45
45
  specification_version: 4
46
46
  summary: IRC bot framework