Class: Irc::Bot::Plugins::PluginManagerClass

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

[] add_botmodule add_botmodule_dir bot_associate cleanup clear_botmodule_dirs commands core_length core_modules delegate help helptopics inspect irc_delegate length mark_priorities_dirty new plugins privmsg register register_map report_error rescan reset_botmodule_lists save scan sort_modules status who_handles?

### 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

new()

### Public Instance methods

[](name)

Returns the botmodule with the given name

add_botmodule(botmodule)
add_botmodule_dir(*dirlist)

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

bot_associate(bot)

Associate with bot bot

cleanup()

call the cleanup method for each active plugin

clear_botmodule_dirs()
commands()

Returns a hash of the registered message prefixes and associated plugins

core_length()
core_modules()

Returns an array of the loaded plugins

delegate(method, m, opts={})
delegate(method, opts={})

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

help(topic="")

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

helptopics()

return list of help topics (plugin names)

inspect()
irc_delegate(method, m)

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

length()
mark_priorities_dirty()

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

plugins()

Returns an array of the loaded plugins

privmsg(m)

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

register(botmodule, cmd, auth_path)

Registers botmodule botmodule with command cmd and command path auth_path

register_map(botmodule, map)

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

report_error(str, err)

Makes a string of error err by adding text str

rescan()

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

reset_botmodule_lists()

Reset lists of botmodules

save()

call the save method for each active plugin

scan()

load plugins from pre-assigned list of directories

sort_modules()
status(short=false)
who_handles?(cmd)

Returns `true` if cmd has already been registered as a command

[Validate]