Class: ProtonBot::Plugin
- Inherits:
-
Object
- Object
- ProtonBot::Plugin
- Defined in:
- lib/protonbot/plugin.rb
Overview
Plugin object. Use it to alter bot’s behavior
Instance Attribute Summary collapse
-
#bot ⇒ Bot
Bot.
-
#core ⇒ Plugin
readonly
Core plugin.
-
#description ⇒ String
readonly
Plugin’s description.
-
#hooks ⇒ Array<Hook>
readonly
Plugin’s hooks.
-
#log ⇒ Object
Returns the value of attribute log.
-
#Log ⇒ LogWrapper
Log.
-
#name ⇒ String
readonly
Plugin’s name.
-
#path ⇒ String
Path.
-
#plugins ⇒ Object
readonly
Returns the value of attribute plugins.
-
#version ⇒ String
readonly
Plugin’s version.
Instance Method Summary collapse
-
#cmd(pattern = {}, &block) ⇒ Hook
Shortcut for ‘hook(type: :command, …) {}`.
-
#emit(dat = {}) ⇒ Object
Emits passed event.
-
#emitt(dat = {}) ⇒ Object
Emits passed event in other thread.
-
#fun(name, &block) ⇒ Object
Shortcut for ‘define_singleton_method(…)`.
-
#hook(pattern = {}, &block) ⇒ Hook
Creates hook and returns it.
-
#initialize(&block) ⇒ Plugin
constructor
A new instance of Plugin.
-
#inspect ⇒ String
Output.
-
#launch ⇒ Plugin
Starts plugin.
-
#run(fname) ⇒ Object
Runs given file (.rb is appended automatically).
Constructor Details
Instance Attribute Details
#bot ⇒ Bot
Returns Bot.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protonbot/plugin.rb', line 21 class ProtonBot::Plugin attr_reader :name, :version, :description, :plugins, :hooks, :core attr_accessor :bot, :log, :path # @param block [Proc] def initialize(&block) @hooks = [] @block = block @numeric = ProtonBot::Numeric end # Starts plugin # @return [Plugin] self def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end # Creates hook and returns it # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end # Shortcut for `hook(type: :command, ...) {}` # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end # Emits passed event # @param dat [Hash<Symbol>] def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end # Emits passed event in other thread # @param dat [Hash<Symbol>] def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end # Runs given file (.rb is appended automatically) # @param fname [String] def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end # Shortcut for `define_singleton_method(...)` # @param name [String,Symbol] # @param block [Proc] def fun(name, &block) define_singleton_method(name, &block) end # @return [String] Output def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end end |
#core ⇒ Plugin (readonly)
Returns Core plugin.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protonbot/plugin.rb', line 21 class ProtonBot::Plugin attr_reader :name, :version, :description, :plugins, :hooks, :core attr_accessor :bot, :log, :path # @param block [Proc] def initialize(&block) @hooks = [] @block = block @numeric = ProtonBot::Numeric end # Starts plugin # @return [Plugin] self def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end # Creates hook and returns it # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end # Shortcut for `hook(type: :command, ...) {}` # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end # Emits passed event # @param dat [Hash<Symbol>] def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end # Emits passed event in other thread # @param dat [Hash<Symbol>] def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end # Runs given file (.rb is appended automatically) # @param fname [String] def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end # Shortcut for `define_singleton_method(...)` # @param name [String,Symbol] # @param block [Proc] def fun(name, &block) define_singleton_method(name, &block) end # @return [String] Output def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end end |
#description ⇒ String (readonly)
Returns Plugin’s description.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protonbot/plugin.rb', line 21 class ProtonBot::Plugin attr_reader :name, :version, :description, :plugins, :hooks, :core attr_accessor :bot, :log, :path # @param block [Proc] def initialize(&block) @hooks = [] @block = block @numeric = ProtonBot::Numeric end # Starts plugin # @return [Plugin] self def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end # Creates hook and returns it # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end # Shortcut for `hook(type: :command, ...) {}` # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end # Emits passed event # @param dat [Hash<Symbol>] def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end # Emits passed event in other thread # @param dat [Hash<Symbol>] def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end # Runs given file (.rb is appended automatically) # @param fname [String] def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end # Shortcut for `define_singleton_method(...)` # @param name [String,Symbol] # @param block [Proc] def fun(name, &block) define_singleton_method(name, &block) end # @return [String] Output def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end end |
#hooks ⇒ Array<Hook> (readonly)
Returns Plugin’s hooks.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protonbot/plugin.rb', line 21 class ProtonBot::Plugin attr_reader :name, :version, :description, :plugins, :hooks, :core attr_accessor :bot, :log, :path # @param block [Proc] def initialize(&block) @hooks = [] @block = block @numeric = ProtonBot::Numeric end # Starts plugin # @return [Plugin] self def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end # Creates hook and returns it # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end # Shortcut for `hook(type: :command, ...) {}` # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end # Emits passed event # @param dat [Hash<Symbol>] def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end # Emits passed event in other thread # @param dat [Hash<Symbol>] def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end # Runs given file (.rb is appended automatically) # @param fname [String] def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end # Shortcut for `define_singleton_method(...)` # @param name [String,Symbol] # @param block [Proc] def fun(name, &block) define_singleton_method(name, &block) end # @return [String] Output def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end end |
#log ⇒ Object
Returns the value of attribute log.
23 24 25 |
# File 'lib/protonbot/plugin.rb', line 23 def log @log end |
#Log ⇒ LogWrapper
Returns Log.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protonbot/plugin.rb', line 21 class ProtonBot::Plugin attr_reader :name, :version, :description, :plugins, :hooks, :core attr_accessor :bot, :log, :path # @param block [Proc] def initialize(&block) @hooks = [] @block = block @numeric = ProtonBot::Numeric end # Starts plugin # @return [Plugin] self def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end # Creates hook and returns it # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end # Shortcut for `hook(type: :command, ...) {}` # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end # Emits passed event # @param dat [Hash<Symbol>] def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end # Emits passed event in other thread # @param dat [Hash<Symbol>] def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end # Runs given file (.rb is appended automatically) # @param fname [String] def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end # Shortcut for `define_singleton_method(...)` # @param name [String,Symbol] # @param block [Proc] def fun(name, &block) define_singleton_method(name, &block) end # @return [String] Output def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end end |
#name ⇒ String (readonly)
Returns Plugin’s name.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protonbot/plugin.rb', line 21 class ProtonBot::Plugin attr_reader :name, :version, :description, :plugins, :hooks, :core attr_accessor :bot, :log, :path # @param block [Proc] def initialize(&block) @hooks = [] @block = block @numeric = ProtonBot::Numeric end # Starts plugin # @return [Plugin] self def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end # Creates hook and returns it # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end # Shortcut for `hook(type: :command, ...) {}` # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end # Emits passed event # @param dat [Hash<Symbol>] def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end # Emits passed event in other thread # @param dat [Hash<Symbol>] def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end # Runs given file (.rb is appended automatically) # @param fname [String] def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end # Shortcut for `define_singleton_method(...)` # @param name [String,Symbol] # @param block [Proc] def fun(name, &block) define_singleton_method(name, &block) end # @return [String] Output def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end end |
#path ⇒ String
Returns Path.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protonbot/plugin.rb', line 21 class ProtonBot::Plugin attr_reader :name, :version, :description, :plugins, :hooks, :core attr_accessor :bot, :log, :path # @param block [Proc] def initialize(&block) @hooks = [] @block = block @numeric = ProtonBot::Numeric end # Starts plugin # @return [Plugin] self def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end # Creates hook and returns it # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end # Shortcut for `hook(type: :command, ...) {}` # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end # Emits passed event # @param dat [Hash<Symbol>] def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end # Emits passed event in other thread # @param dat [Hash<Symbol>] def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end # Runs given file (.rb is appended automatically) # @param fname [String] def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end # Shortcut for `define_singleton_method(...)` # @param name [String,Symbol] # @param block [Proc] def fun(name, &block) define_singleton_method(name, &block) end # @return [String] Output def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end end |
#plugins ⇒ Object (readonly)
Returns the value of attribute plugins.
22 23 24 |
# File 'lib/protonbot/plugin.rb', line 22 def plugins @plugins end |
#version ⇒ String (readonly)
Returns Plugin’s version.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/protonbot/plugin.rb', line 21 class ProtonBot::Plugin attr_reader :name, :version, :description, :plugins, :hooks, :core attr_accessor :bot, :log, :path # @param block [Proc] def initialize(&block) @hooks = [] @block = block @numeric = ProtonBot::Numeric end # Starts plugin # @return [Plugin] self def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end # Creates hook and returns it # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end # Shortcut for `hook(type: :command, ...) {}` # @param pattern [Hash<Symbol>] # @param block [Proc] # @return [Hook] hook def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end # Emits passed event # @param dat [Hash<Symbol>] def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end # Emits passed event in other thread # @param dat [Hash<Symbol>] def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end # Runs given file (.rb is appended automatically) # @param fname [String] def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end # Shortcut for `define_singleton_method(...)` # @param name [String,Symbol] # @param block [Proc] def fun(name, &block) define_singleton_method(name, &block) end # @return [String] Output def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end end |
Instance Method Details
#cmd(pattern = {}, &block) ⇒ Hook
Shortcut for ‘hook(type: :command, …) {}`
61 62 63 |
# File 'lib/protonbot/plugin.rb', line 61 def cmd(pattern = {}, &block) hook(pattern.merge(type: :command), &block) end |
#emit(dat = {}) ⇒ Object
Emits passed event
67 68 69 |
# File 'lib/protonbot/plugin.rb', line 67 def emit(dat = {}) dat[:plug].emit(dat) if dat[:plug] end |
#emitt(dat = {}) ⇒ Object
Emits passed event in other thread
73 74 75 |
# File 'lib/protonbot/plugin.rb', line 73 def emitt(dat = {}) dat[:plug].emitt(dat) if dat[:plug] end |
#fun(name, &block) ⇒ Object
Shortcut for ‘define_singleton_method(…)`
93 94 95 |
# File 'lib/protonbot/plugin.rb', line 93 def fun(name, &block) define_singleton_method(name, &block) end |
#hook(pattern = {}, &block) ⇒ Hook
Creates hook and returns it
51 52 53 54 55 |
# File 'lib/protonbot/plugin.rb', line 51 def hook(pattern = {}, &block) h = ProtonBot::Hook.new(pattern, &block) @hooks << h h end |
#inspect ⇒ String
Returns Output.
98 99 100 |
# File 'lib/protonbot/plugin.rb', line 98 def inspect %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>) end |
#launch ⇒ Plugin
Starts plugin
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/protonbot/plugin.rb', line 34 def launch @plugins = @bot.plugins @core = @bot.plugins['core'] instance_exec(&@block) raise ProtonBot::PluginError, 'Plugin-name is not set!' unless @name raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description raise ProtonBot::PluginError, 'Plugin-description is not set!' unless @description log.info("Started plugin `#{@name} v#{@version}` successfully!") end |
#run(fname) ⇒ Object
Runs given file (.rb is appended automatically)
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/protonbot/plugin.rb', line 79 def run(fname) if @name == 'Core' instance_eval File.read("#{Gem.loaded_specs['protonbot'].lib_dirs_glob}/" \ "protonbot/core_plugin/#{fname}.rb"), "#{name}/#{fname}.rb" else instance_exec do instance_eval File.read(File.("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb" end end end |