Namespace

Included Modules

Class/Module Index [+]

Quicksearch

Cinch::Plugin

This class represents the core of the plugin functionality of Cinch. It provides both the methods for users to write their own plugins as well as for the Cinch framework to use them.

The {ClassMethods} module, which will get included automatically in all classes that include `Cinch::Plugin`, includes all class methods that the user will use for creating plugins.

Most of the instance methods are for use by the Cinch framework and part of the private API, but some will also be used by plugin authors, mainly {config}, {synchronize} and {bot}.

Attributes

bot[R]

@return [Bot]

handlers[R]

@return [Array<Handler>] handlers

timers[R]

@return [Array<Cinch::Timer>]

Public Class Methods

included(by) click to toggle source

@api private

# File lib/cinch/plugin.rb, line 477
def self.included(by)
  by.extend ClassMethods
end
new(bot) click to toggle source

@api private

# File lib/cinch/plugin.rb, line 439
def initialize(bot)
  @bot = bot
  @handlers = []
  @timers   = []
  # @storage  = bot.config.storage.backend.new(@bot.config.storage, self)
  __register
end

Public Instance Methods

__register() click to toggle source

@return [void] @api private

# File lib/cinch/plugin.rb, line 412
def __register
  missing = self.class.check_for_missing_options(@bot)
  unless missing.empty?
    @bot.loggers.warn "[plugin] #{self.class.plugin_name}: Could not register plugin because the following options are not set: #{missing.join(", ")}"
    return
  end

  __register_listeners
  __register_matchers
  __register_ctcps
  __register_timers
  __register_help
end
config() click to toggle source

Provides access to plugin-specific options.

@return [Hash] A hash of options

# File lib/cinch/plugin.rb, line 468
def config
  @bot.config.plugins.options[self.class] || {}
end
shared() click to toggle source
# File lib/cinch/plugin.rb, line 472
def shared
  @bot.config.shared
end
synchronize(*args, &block) click to toggle source

(see Bot#synchronize)

# File lib/cinch/plugin.rb, line 461
def synchronize(*args, &block)
  @bot.synchronize(*args, &block)
end
unregister() click to toggle source

@since 2.0.0

# File lib/cinch/plugin.rb, line 448
def unregister
  @bot.loggers.debug "[plugin] #{self.class.plugin_name}: Unloading plugin"
  @timers.each do |timer|
    timer.stop
  end

  handlers.each do |handler|
    handler.stop
    handler.unregister
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.