diff --git a/plugins.md b/plugins.md index eb818e5..3ccabea 100644 --- a/plugins.md +++ b/plugins.md @@ -2,48 +2,47 @@ A plugin is implemented as a single file in the plugin directory. This is of cou File: echo.pm -#----------------START-------------- -sub { - my( $said ) = @_; - - print "You said: $said->{body}"; -} -#-----------------EOF--------------- +```perl + sub { + my( $said ) = @_; + + print "You said: $said->{body}"; + } +``` File: morecomplicated.pm -#----------------START-------------- -package Bot::BB3::Plugin::Complicated; +```perl + package Bot::BB3::Plugin::Complicated; -sub new { - my( $class ) = @_; - - return bless {}, $class; -} + sub new { + my( $class ) = @_; + + return bless {}, $class; + } -sub initialize { - my( $self ) = @_; + sub initialize { + my( $self ) = @_; - #stuff -} + #stuff + } - #Class name to execute -"Bot::BB3::Plugin::Complicated"; -#-----------------EOF--------------- + #Class name to execute + "Bot::BB3::Plugin::Complicated"; +``` In particular note is the string returned, this is the name of the package to invoke. Note that you could use this as a dummy file to invoke modules installed elsewhere on the system, for example: -File: dummymodule.pm -#----------------START-------------- -use MyModule::Somewhere; +```perl + use MyModule::Somewhere; -"MyModule::Somewhere"; -#-----------------EOF--------------- + "MyModule::Somewhere"; +``` This simply calls 'use' to load the module and then returns the name. -Note that plugins who return a coderef are 'wrapped' by invoking Bot::BB3::PluginWrapper->new( $name, $coderef ); +Note that plugins who return a coderef are 'wrapped' by invoking ```perl Bot::BB3::PluginWrapper->new( $name, $coderef );``` This provides the basic example for implementing a plugin object. More Notes: