protonbot 0.3.4 → 0.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a0949566ae0887a4ee1a5f088d5c04c31e48e7b
4
- data.tar.gz: 8eca8663367b3c77ebf445dbe464cae4cebd8ae0
3
+ metadata.gz: a772965bfa57f36c06a51808af88c35fb4afbc61
4
+ data.tar.gz: 439f4b4d8a940956c5e5beaed8c16ef0d94d7c7f
5
5
  SHA512:
6
- metadata.gz: 6037dc02298ed7f30697fe8329a1a01ea8627ec32b031486ef32e14fa56828ba89133c5372c4054817888c297faeac03bb647e48d37225686111b71fccdfd2a9
7
- data.tar.gz: 773ea673e2555bb281537aaca4254ea562408f260deddae81d81b383969cf9b5894dfed5bb000c77522d2cde3c72e448cc5749f094f066c6daf89e51cddb9fca
6
+ metadata.gz: 5b00a3d7b99320460128b0c8e8dcd7c6b449890d7923d70cd5f2e6c2e62b8cff327949b471ad41e83d68ddc0901f327e387bc6388927e6d39ecf15cdfab38502
7
+ data.tar.gz: de17f7368e8e0df77565bbde008fcbf5659a30a136a821e847c634a8fe911cc8981695eeab3f648510b3a3621fdf5167db7aae4cd09f110bff6a5a97a775c421
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in protonbot.gemspec
4
- gem 'protonbot-chanop', '~> 0.1.0'
5
4
  gemspec
@@ -31,10 +31,12 @@ hook(type: :upart) do |dat|
31
31
 
32
32
  if dat[:nick] == dat[:plug].nick && /requested by .*/.match(dat[:message])
33
33
  dat[:plug].join(dat[:channel])
34
+ elsif dat[:nick] == dat[:plug].nick
35
+ dat[:plug].chans.delete(dat[:channel])
34
36
  end
35
37
  end
36
38
 
37
- hook(type: :uqit) do |dat|
39
+ hook(type: :uquit) do |dat|
38
40
  dat[:plug].chans.each do |chan|
39
41
  chan[:users].delete(dat[:nick]) if chan[:users]
40
42
  end
@@ -13,5 +13,8 @@ hook(type: :ukick) do |dat|
13
13
  dat[:plug].chans[dat[:channel]][:users].delete dat[:target] if
14
14
  dat[:plug].chans[dat[:channel]][:users].include? dat[:target]
15
15
 
16
- dat[:plug].join(dat[:channel]) if dat[:target] == dat[:plug].nick
16
+ if dat[:target] == dat[:plug].nick
17
+ dat[:plug].chans.delete dat[:channel]
18
+ dat[:plug].join(dat[:channel])
19
+ end
17
20
  end
@@ -19,12 +19,14 @@ hook(type: :privmsg) do |dat|
19
19
 
20
20
  # CTCP
21
21
  if dat[:message][0] == "\x01" && dat[:message][-1] == "\x01"
22
- dat[:type] = :ctcp
23
- dat[:message] = dat[:message][1..(dat[:message].length - 2)]
24
- s = dat[:message].split(' ')
25
- dat[:cmd] = s[0]
26
- (dat[:split] = s[1, s.length - 1]) || []
27
- emit(dat)
22
+ dat1 = dat.clone
23
+ dat1[:type] = :ctcp
24
+ dat1[:message] = dat1[:message][1..(dat1[:message].length - 2)]
25
+ s = dat1[:message].split(' ')
26
+ dat1[:cmd] = s[0]
27
+ (dat1[:split] = s[1, s.length - 1]) || []
28
+ privmsg_patch(dat1)
29
+ emit(dat1)
28
30
  end
29
31
 
30
32
  # Command-checker
@@ -52,11 +54,13 @@ hook(type: :notice) do |dat|
52
54
 
53
55
  # CTCP
54
56
  if dat[:message][0] == "\x01" && dat[:message][-1] == "\x01"
55
- dat[:type] = :nctcp
56
- dat[:message] = dat[:message][1..(dat[:message].length - 2)]
57
- s = dat[:message].split(' ')
58
- dat[:cmd] = s[0]
59
- (dat[:split] = s[1, s.length - 1]) || []
60
- emit(dat)
57
+ dat1 = dat.clone
58
+ dat1[:type] = :nctcp
59
+ dat1[:message] = dat1[:message][1..(dat1[:message].length - 2)]
60
+ s = dat1[:message].split(' ')
61
+ dat1[:cmd] = s[0]
62
+ (dat1[:split] = s[1, s.length - 1]) || []
63
+ privmsg_patch(dat1)
64
+ emit(dat1)
61
65
  end
62
66
  end
@@ -3,19 +3,20 @@ class ProtonBot::Plug
3
3
  # @param dat [Hash] Event hash
4
4
  # @return [Plug] self
5
5
  def emit(dat = {})
6
+ hooks = []
6
7
  bot.plugins.each do |_, p|
7
- worked = []
8
- p.hooks.each do |h|
9
- next unless dat >= h.pattern && !worked.include?(h.object_id) && worked.empty?
10
- canrun = true
11
- h.chain.each do |l|
12
- next unless canrun
13
- canrun = l.call(dat, h)
14
- end
15
- worked << h.object_id
16
- h.block.call(dat) if canrun
8
+ hooks += p.hooks
9
+ end
10
+ hooks = hooks.keep_if do |hook|
11
+ dat >= hook.pattern
12
+ end
13
+ hooks.each do |h|
14
+ canrun = true
15
+ h.chain.each do |l|
16
+ next unless canrun
17
+ canrun = l.call(dat, h)
17
18
  end
18
- worked = []
19
+ h.block.call(dat) if canrun
19
20
  end
20
21
  event_locks.each_with_index do |el, k|
21
22
  if dat >= el.pattern
@@ -1,4 +1,4 @@
1
1
  module ProtonBot
2
2
  # ProtonBot's version
3
- VERSION = '0.3.4'.freeze
3
+ VERSION = '0.3.5'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protonbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nickolay Ilyushin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-10 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler