1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 17:35:40 -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
#----------------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: