1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 20:55:39 -04:00

Some formatting help for plugins.md

Ryan Voots 2017-01-05 17:47:00 -05:00
parent 1db4555c3a
commit 87ebf008b0

@ -2,48 +2,47 @@ A plugin is implemented as a single file in the plugin directory. This is of cou
File: echo.pm File: echo.pm
#----------------START-------------- ```perl
sub { sub {
my( $said ) = @_; my( $said ) = @_;
print "You said: $said->{body}"; print "You said: $said->{body}";
} }
#-----------------EOF--------------- ```
File: morecomplicated.pm File: morecomplicated.pm
#----------------START-------------- ```perl
package Bot::BB3::Plugin::Complicated; package Bot::BB3::Plugin::Complicated;
sub new { sub new {
my( $class ) = @_; my( $class ) = @_;
return bless {}, $class; return bless {}, $class;
} }
sub initialize { sub initialize {
my( $self ) = @_; my( $self ) = @_;
#stuff #stuff
} }
#Class name to execute #Class name to execute
"Bot::BB3::Plugin::Complicated"; "Bot::BB3::Plugin::Complicated";
#-----------------EOF--------------- ```
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: 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-------------- ```perl
use MyModule::Somewhere; use MyModule::Somewhere;
"MyModule::Somewhere"; "MyModule::Somewhere";
#-----------------EOF--------------- ```
This simply calls 'use' to load the module and then returns the name. 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. This provides the basic example for implementing a plugin object.
More Notes: More Notes: