mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 20:55:39 -04:00
Some formatting help for plugins.md
parent
1db4555c3a
commit
87ebf008b0
1 changed files with 26 additions and 27 deletions
15
plugins.md
15
plugins.md
|
@ -2,17 +2,17 @@ A plugin is implemented as a single file in the plugin directory. This is of cou
|
|||
|
||||
File: echo.pm
|
||||
|
||||
#----------------START--------------
|
||||
```perl
|
||||
sub {
|
||||
my( $said ) = @_;
|
||||
|
||||
print "You said: $said->{body}";
|
||||
}
|
||||
#-----------------EOF---------------
|
||||
```
|
||||
|
||||
File: morecomplicated.pm
|
||||
|
||||
#----------------START--------------
|
||||
```perl
|
||||
package Bot::BB3::Plugin::Complicated;
|
||||
|
||||
sub new {
|
||||
|
@ -29,21 +29,20 @@ sub initialize {
|
|||
|
||||
#Class name to execute
|
||||
"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:
|
||||
|
||||
File: dummymodule.pm
|
||||
|
||||
#----------------START--------------
|
||||
```perl
|
||||
use MyModule::Somewhere;
|
||||
|
||||
"MyModule::Somewhere";
|
||||
#-----------------EOF---------------
|
||||
```
|
||||
|
||||
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:
|
||||
|
|
Loading…
Add table
Reference in a new issue