protonbot 0.2.7 → 0.3.0

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: c8031a11e22b7ce80ab962f2552bf8677667c1cc
4
- data.tar.gz: 89076fc1c0082722cb99c73069f8a892caf5de6c
3
+ metadata.gz: '084bda3603fab091a4b8804592d075b5b728b9a1'
4
+ data.tar.gz: 3fb9a4aa904ee68554f1f86c845ae5d4a0045213
5
5
  SHA512:
6
- metadata.gz: 0da601d89f36d0df01acb1229a4c560f6bd109a01e541a2cbc42f298f9465b0b239d677a4f328e7bbe4f311af20ed62cb32f6c3a1d0a3ff01ebac0d4969c02cd
7
- data.tar.gz: dbb001abf81f094fdffe89d7ce03087c2a20d8b0ec3342736a5525fde11883be6bde8bee752e80ab17cc8cd8262799955a5480846b76c6d110fa9771e1acf617
6
+ metadata.gz: bdb15bc87df5d29387fdaebf6d63b382f3cb6c5d3d2b5e84b0e7e37b814584c1bc54c6f75b31549516f2148e19341197e2850c8e5dbe1dd2c64b7204ea9ff1d4
7
+ data.tar.gz: 289f79bbb2063c941952e714d7a1d84ecdaae3bac283120306e89c9131d21bc27e6d021fe36a2557507fa1e054675b4fed793f0be0395a48723e7e2021895819
@@ -1,3 +1,4 @@
1
1
  run 'codes/names'
2
2
  run 'codes/welcome'
3
- run 'codes/whois'
3
+ run 'codes/whois'
4
+ run 'codes/topic'
@@ -1,8 +1,11 @@
1
1
  hook(type: :code, code: @numeric::NAMREPLY) do |dat|
2
2
  m = /[=*@] (.+?) :(.+)/.match(dat[:extra])
3
3
 
4
- if !dat[:plug].chans[m[1]] || !dat[:plug].chans[m[1]][:collecting]
4
+ unless dat[:plug].chans[m[1]]
5
5
  dat[:plug].chans[m[1]] = {}
6
+ end
7
+
8
+ unless dat[:plug].chans[m[1]][:collecting]
6
9
  dat[:plug].chans[m[1]][:collecting] = true
7
10
  dat[:plug].chans[m[1]][:users] = []
8
11
  end
@@ -0,0 +1,7 @@
1
+ hook(type: :code, code: @numeric::TOPIC) do |dat|
2
+ m = /(.+?) :(.+)/.match(dat[:extra])
3
+ unless dat[:plug].chans[m[1]]
4
+ dat[:plug].chans[m[1]] = {}
5
+ end
6
+ dat[:plug].chans[m[1]][:topic] = m[2]
7
+ end
@@ -59,39 +59,52 @@ cmd(cmd: 'nick') do |dat|
59
59
  end
60
60
  end.perm!('nick')
61
61
 
62
- core.help_add('admin', 'msg', 'msg [target] <message>', 'Sends given message to target')
62
+ core.help_add('admin', 'msg', 'msg <target> <message>', 'Sends given message to target')
63
63
  cmd(cmd: 'msg') do |dat|
64
64
  if dat[:split].empty?
65
65
  dat.nreply ProtonBot::Messages::NOT_ENOUGH_PARAMETERS
66
66
  else
67
- dat[:plug].privmsg(dat[:split][0], dat[:split][1, dat[:split].length - 1].join(' '))
67
+ dat[:plug].privmsg(dat[:split][0], dat[:split][1, dat[:split].length].join(' '))
68
68
  end
69
69
  end.perm!('msg')
70
70
 
71
- core.help_add('admin', 'ctcp', 'ctcp [target] <message>', 'Sends given ctcp to target')
71
+ core.help_add('admin', 'ctcp', 'ctcp <target> <message>', 'Sends given ctcp to target')
72
72
  cmd(cmd: 'ctcp') do |dat|
73
73
  if dat[:split].empty?
74
74
  dat.nreply ProtonBot::Messages::NOT_ENOUGH_PARAMETERS
75
75
  else
76
- dat[:plug].ctcp(dat[:split][0], dat[:split][1, dat[:split].length - 1].join(' '))
76
+ dat[:plug].ctcp(dat[:split][0], dat[:split][1, dat[:split].length].join(' '))
77
77
  end
78
78
  end.perm!('ctcp')
79
79
 
80
- core.help_add('admin', 'notice', 'notice [target] <message>', 'Sends given notice to target')
80
+ core.help_add('admin', 'action', 'action [target] <message>', 'Sends given ctcp ACTION to target')
81
+ cmd(cmd: 'action') do |dat|
82
+ if dat[:split].empty?
83
+ dat.nreply ProtonBot::Messages::NOT_ENOUGH_PARAMETERS
84
+ else
85
+ if %w(! + # &).include? dat[:split][0][0]
86
+ dat[:plug].action(dat[:split][0], dat[:split][1, dat[:split].length].join(' '))
87
+ else
88
+ dat[:plug].action(dat[:target], dat[:split][0, dat[:split].length].join(' '))
89
+ end
90
+ end
91
+ end.perm!('ctcp')
92
+
93
+ core.help_add('admin', 'notice', 'notice <target> <message>', 'Sends given notice to target')
81
94
  cmd(cmd: 'notice') do |dat|
82
95
  if dat[:split].empty?
83
96
  dat.nreply ProtonBot::Messages::NOT_ENOUGH_PARAMETERS
84
97
  else
85
- dat[:plug].notice(dat[:split][0], dat[:split][1, dat[:split].length - 1].join(' '))
98
+ dat[:plug].notice(dat[:split][0], dat[:split][1, dat[:split].length].join(' '))
86
99
  end
87
100
  end.perm!('notice')
88
101
 
89
- core.help_add('admin', 'nctcp', 'nctcp [target] <message>', 'Sends given nctcp to target')
102
+ core.help_add('admin', 'nctcp', 'nctcp <target> <message>', 'Sends given nctcp to target')
90
103
  cmd(cmd: 'nctcp') do |dat|
91
104
  if dat[:split].empty?
92
105
  dat.nreply ProtonBot::Messages::NOT_ENOUGH_PARAMETERS
93
106
  else
94
- dat[:plug].nctcp(dat[:split][0], dat[:split][1, dat[:split].length - 1].join(' '))
107
+ dat[:plug].nctcp(dat[:split][0], dat[:split][1, dat[:split].length].join(' '))
95
108
  end
96
109
  end.perm!('nctcp')
97
110
 
@@ -1,7 +1,8 @@
1
1
  hook(type: :ctcp, cmd: 'VERSION') do |dat|
2
- dat[:plug].nctcp(dat[:nick], %(VERSION ProtonBot v#{ProtonBot::VERSION} on Ruby ) +
3
- %(v#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}/#{RUBY_PLATFORM} and Heliodor ) +
4
- %(v#{Gem.loaded_specs['heliodor'].version.version}))
2
+ dat[:plug].nctcp(dat[:nick], %(VERSION ) +
3
+ %(%B%C%BLUEProtonBot v#{ProtonBot::VERSION}%N ) +
4
+ %(on %B%C%REDRuby v#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}/#{RUBY_PLATFORM}@#{RUBY_ENGINE}#{RUBY_ENGINE_VERSION}%N ) +
5
+ %(and %B%C%YELLOWHeliodor v#{Gem.loaded_specs['heliodor'].version.version}%N))
5
6
  end
6
7
 
7
8
  hook(type: :ctcp, cmd: 'PING') do |dat|
@@ -5,4 +5,5 @@ run 'hooks/privmsg'
5
5
  run 'hooks/ctcp'
6
6
  run 'hooks/joinpart'
7
7
  run 'hooks/nick'
8
- run 'hooks/sasl'
8
+ run 'hooks/topic'
9
+ run 'hooks/sasl'
@@ -1,7 +1,13 @@
1
1
  hook(type: :unick) do |dat|
2
- u = dat[:plug].users[dat[:nick]].clone
3
- dat[:plug].users.delete(dat[:nick])
4
- dat[:plug].users[dat[:to]] = u
2
+ u = nil
3
+ if dat[:plug].users[dat[:nick]]
4
+ u = dat[:plug].users[dat[:nick]].clone
5
+ dat[:plug].users.delete(dat[:nick])
6
+ dat[:plug].users[dat[:to]] = u
7
+ else
8
+ u = {}
9
+ dat[:plug].users[dat[:nick]] = u
10
+ end
5
11
  u[:nick] = dat[:to]
6
12
  u[:user] = dat[:user]
7
13
  u[:host] = dat[:host]
@@ -17,7 +17,7 @@ hook(type: :raw) do |dat|
17
17
  elsif m = /^:(.+?)!(.+?)@(.+?) NOTICE (.+?) :(.+)/.match(dat[:raw_data])
18
18
  emitt(dat.merge(type: :notice, nick: m[1], user: m[2], host: m[3],
19
19
  target: m[4], message: m[5]))
20
- elsif m = /^:(.+?)!(.+?)@(.+?) TOPIC (.+?) :(.+)/.match(dat[:raw_data]) # NYI
20
+ elsif m = /^:(.+?)!(.+?)@(.+?) TOPIC (.+?) :(.+)/.match(dat[:raw_data])
21
21
  emit(dat.merge(type: :utopic, nick: m[1], user: m[2], host: m[3],
22
22
  channel: m[4], topic: m[5]))
23
23
  elsif m = /^:(.+?)!(.+?)@(.+?) JOIN :(.+)/.match(dat[:raw_data])
@@ -0,0 +1,8 @@
1
+ hook(type: :utopic) do |dat|
2
+ dat[:plug].users[dat[:nick]] = dat[:plug].users[dat[:nick]] or {}
3
+ u = dat[:plug].users[dat[:nick]]
4
+ u[:nick] = dat[:nick]
5
+ u[:user] = dat[:user]
6
+ u[:host] = dat[:host]
7
+ dat[:plug].chans[dat[:chan]][:topic] = dat[:topic]
8
+ end
@@ -95,6 +95,15 @@ class ProtonBot::Plug
95
95
  self
96
96
  end
97
97
 
98
+ # Sends CTCP ACTION to given target
99
+ # @param target [String]
100
+ # @param msg [String]
101
+ # @return [Plug] self
102
+ def action(target, msg)
103
+ ctcp(target, "ACTION #{msg}")
104
+ self
105
+ end
106
+
98
107
  # Sends NCTCP to given target.
99
108
  # @param target [String]
100
109
  # @param msg [String]
@@ -1,4 +1,4 @@
1
1
  module ProtonBot
2
2
  # ProtonBot's version
3
- VERSION = '0.2.7'.freeze
3
+ VERSION = '0.3.0'.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.2.7
4
+ version: 0.3.0
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-02 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,6 +125,7 @@ files:
125
125
  - lib/protonbot/core_plugin/apis/perms.rb
126
126
  - lib/protonbot/core_plugin/codes/index.rb
127
127
  - lib/protonbot/core_plugin/codes/names.rb
128
+ - lib/protonbot/core_plugin/codes/topic.rb
128
129
  - lib/protonbot/core_plugin/codes/welcome.rb
129
130
  - lib/protonbot/core_plugin/codes/whois.rb
130
131
  - lib/protonbot/core_plugin/commands/admin.rb
@@ -143,6 +144,7 @@ files:
143
144
  - lib/protonbot/core_plugin/hooks/privmsg.rb
144
145
  - lib/protonbot/core_plugin/hooks/raw.rb
145
146
  - lib/protonbot/core_plugin/hooks/sasl.rb
147
+ - lib/protonbot/core_plugin/hooks/topic.rb
146
148
  - lib/protonbot/core_plugin/plugin.rb
147
149
  - lib/protonbot/event_lock.rb
148
150
  - lib/protonbot/hook.rb