gruubY 0.2.1 → 0.2.2
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/config/config.rb +1 -1
- data/example/bot.rb +2 -1
- data/lib/gruubY/plugin.rb +17 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf2e8f470f0aaf2f5f1d7da47815232d73fbca532f769721123b76dde1b6aa8d
|
|
4
|
+
data.tar.gz: c6455473f8d0c0b4c508d1e140fda97ace39efdcd2e347e698964f1914206c2a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c52c62f5d0cc407cfcce18ed62af2355bdc53f83fc605af2b47449ecb327f367c9eb79bedae7a6f2181544cb16b89b18fb66a5e78b4325170585a2f361a95f66
|
|
7
|
+
data.tar.gz: e48c0d2f90270f60fbcafaf8bf496238df682da3314883f8f198cf5714c7015096d63b4660e805af68639464efd3c6926d415745923e91f14173e95bf28e8e22
|
data/config/config.rb
CHANGED
data/example/bot.rb
CHANGED
|
@@ -4,7 +4,8 @@ require_relative "../config/config"
|
|
|
4
4
|
client = GrubY::Client.new(Config::TOKEN)
|
|
5
5
|
gm = client.group_manager
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
plugin_file = File.join(__dir__, '../plugins/logger.rb')
|
|
8
|
+
client.use_plugin(plugin_file)
|
|
8
9
|
|
|
9
10
|
HELP = <<~TXT
|
|
10
11
|
Commands:
|
data/lib/gruubY/plugin.rb
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
module GrubY
|
|
2
2
|
class Plugin
|
|
3
3
|
def self.load(bot, path)
|
|
4
|
+
absolute_path = File.expand_path(path, Dir.pwd)
|
|
5
|
+
|
|
6
|
+
unless File.exist?(absolute_path)
|
|
7
|
+
raise "Plugin file not found at: #{absolute_path}"
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
mod = Module.new
|
|
5
|
-
mod.module_eval(File.read(
|
|
11
|
+
mod.module_eval(File.read(absolute_path), absolute_path)
|
|
6
12
|
|
|
7
|
-
if mod.
|
|
13
|
+
if mod.const_defined?(:Plugin)
|
|
14
|
+
plugin_mod = mod.const_get(:Plugin)
|
|
15
|
+
if plugin_mod.respond_to?(:register)
|
|
16
|
+
plugin_mod.register(bot)
|
|
17
|
+
else
|
|
18
|
+
raise "Plugin module in #{path} must define register(bot)"
|
|
19
|
+
end
|
|
20
|
+
elsif mod.respond_to?(:register)
|
|
8
21
|
mod.register(bot)
|
|
9
22
|
else
|
|
10
|
-
raise "Plugin must define register(bot)"
|
|
23
|
+
raise "Plugin in #{path} must define register(bot)"
|
|
11
24
|
end
|
|
12
25
|
end
|
|
13
26
|
end
|
|
14
|
-
end
|
|
27
|
+
end
|