Class: ModSpox::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/mod_spox/Plugin.rb

Instance Method Summary collapse

Constructor Details

#initialize(pipeline) ⇒ Plugin

Returns a new instance of Plugin.

Raises:



6
7
8
9
10
# File 'lib/mod_spox/Plugin.rb', line 6

def initialize(pipeline)
    raise Exceptions::BotException.new('Plugin creation failed to supply message pipeline') unless pipeline.is_a?(Pipeline)
    @pipeline = pipeline
    @pipeline.hook_plugin(self)
end

Instance Method Details

#destroyObject

Called before the object is destroyed by the ModSpox::PluginManager



13
14
15
# File 'lib/mod_spox/Plugin.rb', line 13

def destroy
    Logger.log("Destroy method for plugin #{name} has not been defined.", 15)
end

#meObject

Returns the nick model of the bot



31
32
33
34
35
36
37
38
# File 'lib/mod_spox/Plugin.rb', line 31

def me
    nick = Models::Nick.filter(:botnick => true).first
    if(nick)
        return nick
    else
        raise Exception.new("Fatal Error: I don't know who I am.")
    end
end

#nameObject

Returns the name of the class



18
19
20
# File 'lib/mod_spox/Plugin.rb', line 18

def name
    self.class.name.to_s.gsub(/^.+:/, '')
end

#reply(target, message) ⇒ Object

target

target for message

message

string message

This is a helper method that will send an outgoing Privmsg to the given target



26
27
28
# File 'lib/mod_spox/Plugin.rb', line 26

def reply(target, message)
    @pipeline << Messages::Outgoing::Privmsg.new(target, message)
end