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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65a701817f3bd5ed311e287037e63dcb551aa13292348cbbee6808bb91ba950a
4
- data.tar.gz: 5c7b123dc3b5e9cc58c4369b1578b2f5ccf299d6dcebd203aa7f1be13642bbee
3
+ metadata.gz: cf2e8f470f0aaf2f5f1d7da47815232d73fbca532f769721123b76dde1b6aa8d
4
+ data.tar.gz: c6455473f8d0c0b4c508d1e140fda97ace39efdcd2e347e698964f1914206c2a
5
5
  SHA512:
6
- metadata.gz: 543ca64c807a610c59626411d2c53cbdef45987e3eb23d5d5388f6d590b8c645db169487969521fc95db1bba7c018a60a576de5279b29570542dc16d264c9b3f
7
- data.tar.gz: 504d897c1e70bbf554ed931882c5af2a06f9202e3955ceef94e0df5442450750bfcea73106cb438af72a99a969eb412042e4f184e11f0a8dc43e46447fd66ef9
6
+ metadata.gz: c52c62f5d0cc407cfcce18ed62af2355bdc53f83fc605af2b47449ecb327f367c9eb79bedae7a6f2181544cb16b89b18fb66a5e78b4325170585a2f361a95f66
7
+ data.tar.gz: e48c0d2f90270f60fbcafaf8bf496238df682da3314883f8f198cf5714c7015096d63b4660e805af68639464efd3c6926d415745923e91f14173e95bf28e8e22
data/config/config.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Config
2
- TOKEN = "7543495331:AAHLYllkmBjf0VjKy4qxLSlA7DBA45htvdQ"
2
+ TOKEN = ""
3
3
  WEBHOOK_PATH = "/webhook"
4
4
  PORT = 4545
5
5
  end
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
- client.use_plugin("../plugins/logger.rb")
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(path), path)
11
+ mod.module_eval(File.read(absolute_path), absolute_path)
6
12
 
7
- if mod.respond_to?(:register)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gruubY
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sreyanshu