protonbot 0.3.2 → 0.3.3
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 +4 -4
- data/lib/protonbot/bot.rb +2 -1
- data/lib/protonbot/bot_plugins.rb +17 -9
- data/lib/protonbot/core_plugin/apis/cooldowns.rb +1 -1
- data/lib/protonbot/core_plugin/commands/basic.rb +5 -0
- data/lib/protonbot/core_plugin/plugin.rb +0 -2
- data/lib/protonbot/plugin.rb +3 -4
- data/lib/protonbot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e32dd98edcadebac541ea89e89c7d9945ea50929
|
4
|
+
data.tar.gz: d5a72e64cdea4d2aeb3d29739299b1c7d55d3357
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c32605501bc4afbe317b9fed90af8b6af7a33416ca88c97fef20b41ef160068b5a6130c06271eb90c06c07a5377abf3f29724e3d05ff0e9d672cf93f48107d3e
|
7
|
+
data.tar.gz: 873895ef9bee5c6d63a419747249043d861e2196fba9b47c789a1a005a2fe1b9ad31b7b9bd59c50cbda8ae67f6ba1586962476058467bc2b5a9e300d54e9f93c
|
data/lib/protonbot/bot.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Main bot class. Use it to create the bot
|
2
2
|
class ProtonBot::Bot
|
3
|
-
attr_reader :log, :_log, :dbs, :plugins, :conf, :plugs, :plugthrs
|
3
|
+
attr_reader :log, :_log, :dbs, :plugins, :conf, :plugs, :plugthrs, :core
|
4
4
|
|
5
5
|
# @yield Main bot's block. You'll use it for configuring bot.
|
6
6
|
def initialize(&block)
|
@@ -15,6 +15,7 @@ class ProtonBot::Bot
|
|
15
15
|
configure
|
16
16
|
@log.info('Processed config block')
|
17
17
|
|
18
|
+
@parr = []
|
18
19
|
@plugins = {}
|
19
20
|
plugins_load
|
20
21
|
@log.info('Processed plugins block')
|
@@ -39,14 +39,22 @@ class ProtonBot::Bot
|
|
39
39
|
# each plugin
|
40
40
|
# @return [Bot] self
|
41
41
|
def plugins_load
|
42
|
-
|
43
|
-
|
42
|
+
core = pluginr "#{Gem.loaded_specs['protonbot'].lib_dirs_glob.split(':')[0]}/protonbot/core_plugin/plugin.rb"
|
43
|
+
core.bot = self
|
44
|
+
core.core = core
|
45
|
+
core.launch
|
46
|
+
@core = core
|
47
|
+
@plugins[core.name] = core
|
48
|
+
core.log = @_log.wrap("?#{core.name}")
|
49
|
+
core.log.info("Started plugin `#{core.name} v#{core.version}` successfully!")
|
44
50
|
@plugin_loader.call if @plugin_loader
|
45
|
-
@
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
@parr.each do |pl|
|
52
|
+
pl.bot = self
|
53
|
+
pl.core = @plugins[core.name]
|
54
|
+
pl.launch
|
55
|
+
@plugins[pl.name] = pl
|
56
|
+
pl.log = @_log.wrap("?#{pl.name}")
|
57
|
+
pl.log.info("Started plugin `#{pl.name} v#{pl.version}` successfully!")
|
50
58
|
end
|
51
59
|
self
|
52
60
|
end
|
@@ -69,7 +77,7 @@ class ProtonBot::Bot
|
|
69
77
|
else
|
70
78
|
raise ArgumentError, 'Unknown type of `dat` plugin! Use Array or String!'
|
71
79
|
end
|
72
|
-
@
|
80
|
+
@parr << pl
|
73
81
|
self
|
74
82
|
end
|
75
83
|
|
@@ -85,7 +93,7 @@ class ProtonBot::Bot
|
|
85
93
|
pl = pluginr(path)
|
86
94
|
raise ProtonBot::PluginError, "`#{path}` did not return plugin!" unless
|
87
95
|
pl.instance_of? ProtonBot::Plugin
|
88
|
-
@
|
96
|
+
@parr << pl
|
89
97
|
else
|
90
98
|
raise IOError, "No such file or directory: #{path}"
|
91
99
|
end
|
@@ -25,7 +25,7 @@ class ProtonBot::Hook
|
|
25
25
|
when :user_and_target
|
26
26
|
:"last_used_#{dat[:plug].name}_#{dat[:target]}_#{dat[:host]}"
|
27
27
|
end
|
28
|
-
if dat[:bot].
|
28
|
+
if dat[:bot].core.getpermsr(dat[:plug], dat[:host]).include? 'nocooldown'
|
29
29
|
true
|
30
30
|
elsif hook.extra[lu_sign]
|
31
31
|
curtime = Time.now.to_i
|
@@ -7,3 +7,8 @@ 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
9
|
end.cooldown!(5)
|
10
|
+
|
11
|
+
core.help_add('basic', 'plugins', 'plugins', 'List of plugins')
|
12
|
+
cmd(cmd: 'plugins') do |dat|
|
13
|
+
dat.nreply("%BAvailable plugins:%N #{bot.plugins.map{|_,p|p.name + ' v' + p.version}.join(', ')}")
|
14
|
+
end.cooldown!(10)
|
data/lib/protonbot/plugin.rb
CHANGED
@@ -16,11 +16,11 @@
|
|
16
16
|
# @return [LogWrapper] Log
|
17
17
|
# @!attribute [rw] path
|
18
18
|
# @return [String] Path
|
19
|
-
# @!attribute [
|
19
|
+
# @!attribute [rw] core
|
20
20
|
# @return [Plugin] Core plugin
|
21
21
|
class ProtonBot::Plugin
|
22
|
-
attr_reader :name, :version, :description, :plugins, :hooks
|
23
|
-
attr_accessor :bot, :log, :path
|
22
|
+
attr_reader :name, :version, :description, :plugins, :hooks
|
23
|
+
attr_accessor :bot, :log, :path, :core
|
24
24
|
|
25
25
|
# @param block [Proc]
|
26
26
|
def initialize(&block)
|
@@ -33,7 +33,6 @@ class ProtonBot::Plugin
|
|
33
33
|
# @return [Plugin] self
|
34
34
|
def launch
|
35
35
|
@plugins = @bot.plugins
|
36
|
-
@core = @bot.plugins['core']
|
37
36
|
instance_exec(&@block)
|
38
37
|
raise ProtonBot::PluginError, 'Plugin-name is not set!' unless
|
39
38
|
@name
|
data/lib/protonbot/version.rb
CHANGED