protonbot 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0109257db5937971a7fd55f01a8b13bec2c143f4'
4
- data.tar.gz: 717498471069d2411ad8f3660eccbfebdc46c1b2
3
+ metadata.gz: 838a7550d682f68d55fd9c8ffc7bb42f3f428562
4
+ data.tar.gz: f1e5369b958f2b889cbe657a0a4522a0be768791
5
5
  SHA512:
6
- metadata.gz: 6d49607f06931d18011aa0e223a26dbe1264ae6712eb32b4afcb2edbe8cac35230a6078b0bc9bcb1c72f45b0b832f8c8e538510d89c4f0c7a0b439e4edf243d1
7
- data.tar.gz: a4d79322c7d75d587e8b678ccb830ee4dc363411ed3a5a8dd1cf855cf1d461b0f14348bbcd43f7695125e78c21d3b8d512117a290f4e82e95a358ba7f39fbdfa
6
+ metadata.gz: 5dcd94907a5b48c96a6cdd2f70895c1e2319e39e08cdeb25c05476df2252a14d9fb26cace45c9f9200c09b715257248ea7f097446756e1c25a41a6e21ceb5ac5
7
+ data.tar.gz: 0f10bdea18ea063c5d2706095ac753f85d361a8c9fb7d87c86be6d7dd25dd057ad5c0742cb5f1da5ea91cc13fa4c251b4ae9d836d6739d52f75278a9324e72a0
@@ -0,0 +1,24 @@
1
+ class ProtonBot::Hook
2
+ def cooldown!(seconds, verbose = true)
3
+ self.extra[:cooldown_seconds] = seconds
4
+ self.extra[:cooldown_verbose] = verbose
5
+ self.chain << proc do |dat, hook|
6
+ if dat[:bot].plugins['core'].getpermsr(dat[:plug], dat[:host]).include? 'nocooldown'
7
+ true
8
+ elsif hook.extra[:last_used]
9
+ curtime = Time.now.to_i
10
+ cmp = hook.extra[:last_used] - curtime + hook.extra[:cooldown_seconds]
11
+ if (cmp) <= 0
12
+ hook.extra[:last_used] = curtime
13
+ true
14
+ else
15
+ dat.nreply("You need to wait %B#{cmp}%N more seconds to use this!")
16
+ false
17
+ end
18
+ else
19
+ hook.extra[:last_used] = Time.now.to_i
20
+ true
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,2 +1,3 @@
1
1
  run 'apis/perms'
2
+ run 'apis/cooldowns'
2
3
  run 'apis/help'
@@ -44,6 +44,7 @@ end
44
44
  notice
45
45
  nctcp
46
46
  flushq
47
+ nocooldown
47
48
  ),
48
49
  'cross' => %w(
49
50
  crossuser
@@ -82,6 +83,10 @@ fun :getperms do |plug, host|
82
83
  end
83
84
  end
84
85
 
86
+ fun :getpermsr do |plug, host|
87
+ process_perms(getperms!(plug, host))
88
+ end
89
+
85
90
  fun :hasperm? do |plug, host, perm|
86
91
  dat = plug.db.query('perms').ensure.select('host' => host).finish
87
92
  perms = dat[0].to_h['perms'] unless dat.empty?
@@ -98,6 +98,7 @@ end.perm!('nctcp')
98
98
  core.help_add('admin', 'flushq', 'flushq', 'Flushes queue')
99
99
  cmd(cmd: 'flushq') do |dat|
100
100
  dat[:plug].queue.clear
101
+ dat.nreply 'Write queue is empty now!'
101
102
  end.perm!('flushq')
102
103
 
103
104
  core.help_add('owner', 'r', 'r', 'Reloads all plugins')
@@ -1,9 +1,9 @@
1
1
  core.help_add('basic', 'ping', 'ping', 'Ping!')
2
2
  cmd(cmd: 'ping') do |dat|
3
3
  dat.reply("#{dat[:nick]}: pong!")
4
- end
4
+ end.cooldown!(5)
5
5
 
6
6
  core.help_add('basic', 'echo', 'echo', 'Sends given message back')
7
7
  cmd(cmd: 'echo') do |dat|
8
8
  dat.reply("#{dat[:split].join(' ')}")
9
- end
9
+ end.cooldown!(5)
@@ -16,7 +16,7 @@ hook(type: :command, cmd: 'part') do |dat|
16
16
  if dat[:split].empty?
17
17
  dat[:plug].part(dat[:target], '')
18
18
  else
19
- (reason = dat[:split][1]) || ''
19
+ reason = dat[:split][1,dat[:split].length-1].join(' ') || ''
20
20
  chans = dat[:split][0].split(',')
21
21
  chans.each do |chan|
22
22
  dat[:plug].part(chan, reason)
@@ -1,4 +1,4 @@
1
1
  module ProtonBot
2
2
  # ProtonBot's version
3
- VERSION = '0.2.3'.freeze
3
+ VERSION = '0.2.4'.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.3
4
+ version: 0.2.4
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-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -119,6 +119,7 @@ files:
119
119
  - lib/protonbot/bot.rb
120
120
  - lib/protonbot/bot_conf.rb
121
121
  - lib/protonbot/bot_plugins.rb
122
+ - lib/protonbot/core_plugin/apis/cooldowns.rb
122
123
  - lib/protonbot/core_plugin/apis/help.rb
123
124
  - lib/protonbot/core_plugin/apis/index.rb
124
125
  - lib/protonbot/core_plugin/apis/perms.rb