lib/protonbot/bot_plugins.rb in protonbot-0.3.2 vs lib/protonbot/bot_plugins.rb in protonbot-0.3.3
- old
+ new
@@ -37,18 +37,26 @@
# Loads all plugins by calling `@plugin_loader` and initializing
# each plugin
# @return [Bot] self
def plugins_load
- @plugins['core'] =
- pluginr "#{Gem.loaded_specs['protonbot'].lib_dirs_glob.split(':')[0]}/protonbot/core_plugin/plugin.rb"
+ core = pluginr "#{Gem.loaded_specs['protonbot'].lib_dirs_glob.split(':')[0]}/protonbot/core_plugin/plugin.rb"
+ core.bot = self
+ core.core = core
+ core.launch
+ @core = core
+ @plugins[core.name] = core
+ core.log = @_log.wrap("?#{core.name}")
+ core.log.info("Started plugin `#{core.name} v#{core.version}` successfully!")
@plugin_loader.call if @plugin_loader
- @plugins.each do |k, v|
- v.bot = self
- v.launch
- v.log = @_log.wrap("?#{v.name}")
- v.log.info("Started plugin `#{v.name} v#{v.version}` successfully!")
+ @parr.each do |pl|
+ pl.bot = self
+ pl.core = @plugins[core.name]
+ pl.launch
+ @plugins[pl.name] = pl
+ pl.log = @_log.wrap("?#{pl.name}")
+ pl.log.info("Started plugin `#{pl.name} v#{pl.version}` successfully!")
end
self
end
# Loads given plugin by name
@@ -67,11 +75,11 @@
raise ProtonBot::PluginError, "`plugins/#{dat}/plugin.rb` did not return plugin!" unless
pl.instance_of? ProtonBot::Plugin
else
raise ArgumentError, 'Unknown type of `dat` plugin! Use Array or String!'
end
- @plugins[pl.name] = pl
+ @parr << pl
self
end
# Loads plugin from gem
# @param gemname [String] Name of gem
@@ -83,10 +91,10 @@
"#{gemname.gsub(/-/, '/')}/plugin.rb"
if File.exist? path
pl = pluginr(path)
raise ProtonBot::PluginError, "`#{path}` did not return plugin!" unless
pl.instance_of? ProtonBot::Plugin
- @plugins[gemname] = pl
+ @parr << pl
else
raise IOError, "No such file or directory: #{path}"
end
else
raise ArgumentError, "No such gem: #{gemname}"