Plugins are now autoloaded via entries listed in the Plugin/autoload file

This commit is contained in:
Pragmatic Software 2019-12-21 15:26:01 -08:00
parent 7506de77bc
commit 4d9b3f09a7
4 changed files with 24 additions and 8 deletions

View File

@ -52,7 +52,14 @@ sub autoload {
$self->{pbot}->{logger}->log("Loading plugins ...\n");
my $plugin_count = 0;
my @plugins = glob "$path/*.pm";
my $fh;
if (not open $fh, "<$path/autoload") {
$self->{pbot}->{logger}->log("warning: file $path/autoload does not exist; skipping autoloading of Plugins\n");
return;
}
chomp(my @plugins = <$fh>);
close $fh;
foreach my $plugin (sort @plugins) {
$plugin = basename $plugin;

View File

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
package Plugins::_Example;
package Plugins::Example;
use warnings;
use strict;
@ -44,7 +44,7 @@ sub on_public {
return 0;
}
$self->{pbot}->{logger}->log("_Example plugin: got message from $nick!$user\@$host: $msg\n");
$self->{pbot}->{logger}->log("Example plugin: got message from $nick!$user\@$host: $msg\n");
return 0;
}

View File

@ -1,8 +1,6 @@
Loadable plugins live here.
All files not beginning with an underscore will be automatically loaded
at bot start-up.
All files listed in the `autoload` file will be loaded at bot start-up.
Plugins (including those starting with an underscore) can be manually loaded
or unloaded with the `plug` and `unplug` commands. Use `pluglist` to list
loaded plugins.
Plugins can be manually loaded or unloaded with the `plug` and `unplug`
commands. Use `pluglist` to list loaded plugins.

11
Plugins/autoload Normal file
View File

@ -0,0 +1,11 @@
ActionTrigger.pm
AntiAway.pm
AntiKickAutoRejoin.pm
AntiNickSpam.pm
AntiRepeat.pm
AntiTwitter.pm
AutoRejoin.pm
Counter.pm
Quotegrabs.pm
RemindMe.pm
UrlTitles.pm