Class Irc::Bot::Plugins::PluginManagerClass
In: lib/rbot/plugins.rb
Parent: Object

Singleton to manage multiple plugins and delegate messages to them for handling

Methods

Included Modules

Singleton

Constants

DEFAULT_DELEGATE_PATTERNS = %r{^(?: connect|names|nick| listen|ctcp_listen|privmsg|unreplied| kick|join|part|quit| save|cleanup|flush_registry| set_.*|event_.* )$}x   This is the list of patterns commonly delegated to plugins. A fast delegation lookup is enabled for them.

Attributes

bot  [R] 
botmodules  [R] 
maps  [R] 

Public Class methods

Public Instance methods

Returns the botmodule with the given name

add one or more directories to the list of directories to load botmodules from

TODO find a way to specify necessary plugins which must be loaded

Associate with bot bot

call the cleanup method for each active plugin

Returns a hash of the registered message prefixes and associated plugins

Returns an array of the loaded plugins

see if each plugin handles method, and if so, call it, passing m as a parameter (if present). BotModules are called in order of priority from lowest to highest.

If the passed m is a BasicUserMessage and is marked as ignored?, it will only be delegated to plugins with negative priority. Conversely, if it‘s a fake message (see BotModule#fake_message), it will only be delegated to plugins with positive priority.

Note that m can also be an exploded Array, but in this case the last element of it cannot be a Hash, or it will be interpreted as the options Hash for delegate itself. The last element can be a subclass of a Hash, though. To be on the safe side, you can add an empty Hash as last parameter for delegate when calling it with an exploded Array:

  @bot.plugins.delegate(method, *(args.push Hash.new))

Currently supported options are the following:

:above :if specified, the delegation will only consider plugins with a priority higher than the specified value
:below :if specified, the delegation will only consider plugins with a priority lower than the specified value

return help for topic (call associated plugin‘s help method)

return list of help topics (plugin names)

delegate IRC messages, by delegating ‘listen’ first, and the actual method afterwards. Delegating ‘privmsg’ also delegates ctcp_listen and message as appropriate.

Tells the PluginManager that the next time it delegates an event, it should sort the modules by priority

Returns an array of the loaded plugins

see if we have a plugin that wants to handle this message, if so, pass it to the plugin and return true, otherwise false

Registers botmodule botmodule with command cmd and command path auth_path

Registers botmodule botmodule with map map. This adds the map to the maps hash which has three keys:

botmodule:the associated botmodule
auth:an array of auth keys checked by the map; the first is the full_auth_path of the map
map:the actual MessageTemplate object

Makes a string of error err by adding text str

drop all plugins and rescan plugins on disk calls save and cleanup for each plugin before dropping them

Reset lists of botmodules

call the save method for each active plugin

load plugins from pre-assigned list of directories

Returns true if cmd has already been registered as a command

[Validate]