Class: ProtonBot::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/protonbot/plugin.rb

Overview

Plugin object. Use it to alter bot’s behavior

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Plugin



26
27
28
29
30
# File 'lib/protonbot/plugin.rb', line 26

def initialize(&block)
  @hooks = []
  @block = block
  @numeric = ProtonBot::Numeric
end

Instance Attribute Details

#botBot



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
# File 'lib/protonbot/plugin.rb', line 21

class ProtonBot::Plugin
  attr_reader :name, :version, :description, :plugins, :hooks
  attr_accessor :bot, :log, :path, :core

  # @param block [Proc]
  def initialize(&block)
    @hooks = []
    @block = block
    @numeric = ProtonBot::Numeric
  end

  # Starts plugin
  # @return [Plugin] self
  def launch
    @plugins = @bot.plugins
    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
  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.expand_path("#{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

#corePlugin



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
# File 'lib/protonbot/plugin.rb', line 21

class ProtonBot::Plugin
  attr_reader :name, :version, :description, :plugins, :hooks
  attr_accessor :bot, :log, :path, :core

  # @param block [Proc]
  def initialize(&block)
    @hooks = []
    @block = block
    @numeric = ProtonBot::Numeric
  end

  # Starts plugin
  # @return [Plugin] self
  def launch
    @plugins = @bot.plugins
    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
  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.expand_path("#{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

#descriptionString (readonly)



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
# File 'lib/protonbot/plugin.rb', line 21

class ProtonBot::Plugin
  attr_reader :name, :version, :description, :plugins, :hooks
  attr_accessor :bot, :log, :path, :core

  # @param block [Proc]
  def initialize(&block)
    @hooks = []
    @block = block
    @numeric = ProtonBot::Numeric
  end

  # Starts plugin
  # @return [Plugin] self
  def launch
    @plugins = @bot.plugins
    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
  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.expand_path("#{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

#hooksArray<Hook> (readonly)



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
# File 'lib/protonbot/plugin.rb', line 21

class ProtonBot::Plugin
  attr_reader :name, :version, :description, :plugins, :hooks
  attr_accessor :bot, :log, :path, :core

  # @param block [Proc]
  def initialize(&block)
    @hooks = []
    @block = block
    @numeric = ProtonBot::Numeric
  end

  # Starts plugin
  # @return [Plugin] self
  def launch
    @plugins = @bot.plugins
    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
  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.expand_path("#{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

#logObject

Returns the value of attribute log.



23
24
25
# File 'lib/protonbot/plugin.rb', line 23

def log
  @log
end

#LogLogWrapper



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
# File 'lib/protonbot/plugin.rb', line 21

class ProtonBot::Plugin
  attr_reader :name, :version, :description, :plugins, :hooks
  attr_accessor :bot, :log, :path, :core

  # @param block [Proc]
  def initialize(&block)
    @hooks = []
    @block = block
    @numeric = ProtonBot::Numeric
  end

  # Starts plugin
  # @return [Plugin] self
  def launch
    @plugins = @bot.plugins
    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
  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.expand_path("#{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

#nameString (readonly)



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
# File 'lib/protonbot/plugin.rb', line 21

class ProtonBot::Plugin
  attr_reader :name, :version, :description, :plugins, :hooks
  attr_accessor :bot, :log, :path, :core

  # @param block [Proc]
  def initialize(&block)
    @hooks = []
    @block = block
    @numeric = ProtonBot::Numeric
  end

  # Starts plugin
  # @return [Plugin] self
  def launch
    @plugins = @bot.plugins
    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
  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.expand_path("#{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

#pathString



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
# File 'lib/protonbot/plugin.rb', line 21

class ProtonBot::Plugin
  attr_reader :name, :version, :description, :plugins, :hooks
  attr_accessor :bot, :log, :path, :core

  # @param block [Proc]
  def initialize(&block)
    @hooks = []
    @block = block
    @numeric = ProtonBot::Numeric
  end

  # Starts plugin
  # @return [Plugin] self
  def launch
    @plugins = @bot.plugins
    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
  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.expand_path("#{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

#pluginsObject (readonly)

Returns the value of attribute plugins.



22
23
24
# File 'lib/protonbot/plugin.rb', line 22

def plugins
  @plugins
end

#versionString (readonly)



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
# File 'lib/protonbot/plugin.rb', line 21

class ProtonBot::Plugin
  attr_reader :name, :version, :description, :plugins, :hooks
  attr_accessor :bot, :log, :path, :core

  # @param block [Proc]
  def initialize(&block)
    @hooks = []
    @block = block
    @numeric = ProtonBot::Numeric
  end

  # Starts plugin
  # @return [Plugin] self
  def launch
    @plugins = @bot.plugins
    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
  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.expand_path("#{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, …) {}`



59
60
61
# File 'lib/protonbot/plugin.rb', line 59

def cmd(pattern = {}, &block)
  hook(pattern.merge(type: :command), &block)
end

#emit(dat = {}) ⇒ Object

Emits passed event



65
66
67
# File 'lib/protonbot/plugin.rb', line 65

def emit(dat = {})
  dat[:plug].emit(dat) if dat[:plug]
end

#emitt(dat = {}) ⇒ Object

Emits passed event in other thread



71
72
73
# File 'lib/protonbot/plugin.rb', line 71

def emitt(dat = {})
  dat[:plug].emitt(dat) if dat[:plug]
end

#fun(name, &block) ⇒ Object

Shortcut for ‘define_singleton_method(…)`



91
92
93
# File 'lib/protonbot/plugin.rb', line 91

def fun(name, &block)
  define_singleton_method(name, &block)
end

#hook(pattern = {}, &block) ⇒ Hook

Creates hook and returns it



49
50
51
52
53
# File 'lib/protonbot/plugin.rb', line 49

def hook(pattern = {}, &block)
  h = ProtonBot::Hook.new(pattern, &block)
  @hooks << h
  h
end

#inspectString



96
97
98
# File 'lib/protonbot/plugin.rb', line 96

def inspect
  %(<#ProtonBot::Plugin:#{object_id.to_s(16)} @name=#{name} @version=#{version}>)
end

#launchPlugin

Starts plugin

Raises:

  • (ProtonBot::PluginError)


34
35
36
37
38
39
40
41
42
43
# File 'lib/protonbot/plugin.rb', line 34

def launch
  @plugins = @bot.plugins
  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
end

#run(fname) ⇒ Object

Runs given file (.rb is appended automatically)



77
78
79
80
81
82
83
84
85
86
# File 'lib/protonbot/plugin.rb', line 77

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.expand_path("#{path}/#{fname}.rb")), "#{name}/#{fname}.rb"
    end
  end
end