mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 20:22:37 +01:00
Make directory structure more Perlish
This commit is contained in:
parent
c2dd870172
commit
34d4722580
2
data/last_update
vendored
2
data/last_update
vendored
@ -1 +1 @@
|
||||
4149
|
||||
4185
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Purpose: IRC Bot
|
||||
#
|
||||
# PBot was started around 2001, 2002. It has been lovingly maintained;
|
||||
# PBot was started around 2004, 2005. It has been lovingly maintained;
|
||||
# however, it does use the ancient but simple Net::IRC package (if it
|
||||
# ain't broke) instead of packages based on significantly more complex
|
||||
# Enterprise-level event-loop frameworks. PBot uses pure Perl 5 blessed
|
||||
@ -89,7 +89,6 @@ sub initialize {
|
||||
$value =~ s/[\\\/]$//; # strip trailing directory separator
|
||||
$conf{data_dir} = $value if $override eq 'data_dir';
|
||||
$conf{module_dir} = $value if $override eq 'module_dir';
|
||||
$conf{plugin_dir} = $value if $override eq 'plugin_dir';
|
||||
$conf{update_dir} = $value if $override eq 'update_dir';
|
||||
} else {
|
||||
# check command-line arguments for registry overrides
|
||||
@ -113,7 +112,7 @@ sub initialize {
|
||||
}
|
||||
|
||||
# make sure the paths exist
|
||||
foreach my $path (qw/data_dir module_dir plugin_dir update_dir/) {
|
||||
foreach my $path (qw/data_dir module_dir update_dir/) {
|
||||
if (not -d $conf{$path}) {
|
||||
print STDERR "$path path ($conf{$path}) does not exist; aborting.\n";
|
||||
exit;
|
||||
@ -140,7 +139,6 @@ sub initialize {
|
||||
|
||||
# log configured paths
|
||||
$self->{logger}->log("module_dir: $conf{module_dir}\n");
|
||||
$self->{logger}->log("plugin_dir: $conf{plugin_dir}\n");
|
||||
$self->{logger}->log(" data_dir: $conf{data_dir}\n");
|
||||
$self->{logger}->log("update_dir: $conf{update_dir}\n");
|
||||
|
@ -34,8 +34,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::ActionTrigger;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::ActionTrigger;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::AntiAway;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::AntiAway;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::AntiKickAutoRejoin;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::AntiKickAutoRejoin;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -6,8 +6,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::AntiNickSpam;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::AntiNickSpam;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::AntiRepeat;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::AntiRepeat;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -6,8 +6,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::AntiTwitter;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::AntiTwitter;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::AutoRejoin;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::AutoRejoin;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
use Time::Duration;
|
@ -1,11 +1,11 @@
|
||||
# File: Plugin.pm
|
||||
# File: Base.pm
|
||||
#
|
||||
# Purpose: Base class for PBot plugins.
|
||||
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Plugin;
|
||||
package PBot::Plugin::Base;
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -24,8 +24,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Battleship;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Battleship;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -6,8 +6,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Connect4;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Connect4;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -6,8 +6,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Counter;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Counter;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Date;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Date;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Example;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Example;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::FuncBuiltins;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::FuncBuiltins;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::FuncGrep;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::FuncGrep;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::FuncPlural;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::FuncPlural;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::FuncSed;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::FuncSed;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -6,8 +6,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::GoogleSearch;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::GoogleSearch;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -6,8 +6,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::ParseDate;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::ParseDate;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -6,8 +6,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Plang;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Plang;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -8,8 +8,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Quotegrabs;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Quotegrabs;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
||||
@ -18,9 +18,8 @@ use Time::Duration;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
use Getopt::Long qw(GetOptionsFromArray);
|
||||
|
||||
use Plugins::Quotegrabs::Quotegrabs_SQLite; # use SQLite backend for quotegrabs database
|
||||
|
||||
#use Plugins::Quotegrabs::Quotegrabs_Hashtable; # use Perl hashtable backend for quotegrabs database
|
||||
use PBot::Plugin::Quotegrabs::Quotegrabs_SQLite; # use SQLite backend for quotegrabs database
|
||||
#use PBot::Plugin::Quotegrabs::Quotegrabs_Hashtable; # use Perl hashtable backend for quotegrabs database
|
||||
use PBot::Utils::ValidateString;
|
||||
|
||||
use POSIX qw(strftime);
|
||||
@ -29,9 +28,8 @@ sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{filename} = $conf{quotegrabs_file} // $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/quotegrabs.sqlite3';
|
||||
|
||||
$self->{database} = Plugins::Quotegrabs::Quotegrabs_SQLite->new(pbot => $self->{pbot}, filename => $self->{filename});
|
||||
|
||||
#$self->{database} = Plugins::Quotegrabs::Quotegrabs_Hashtable->new(pbot => $self->{pbot}, filename => $self->{filename});
|
||||
$self->{database} = PBot::Plugin::Quotegrabs::Quotegrabs_SQLite->new(pbot => $self->{pbot}, filename => $self->{filename});
|
||||
#$self->{database} = PBot::Plugin::Quotegrabs::Quotegrabs_Hashtable->new(pbot => $self->{pbot}, filename => $self->{filename});
|
||||
$self->{database}->begin();
|
||||
|
||||
$self->{pbot}->{atexit}->register(sub { $self->{database}->end(); return; });
|
@ -5,12 +5,9 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Quotegrabs::Quotegrabs_Hashtable;
|
||||
package PBot::Plugin::Quotegrabs::Quotegrabs_Hashtable;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use feature 'unicode_strings';
|
||||
use PBot::Imports;
|
||||
|
||||
use HTML::Entities;
|
||||
use Time::Duration;
|
@ -5,12 +5,9 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Quotegrabs::Quotegrabs_SQLite;
|
||||
package PBot::Plugin::Quotegrabs::Quotegrabs_SQLite;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use feature 'unicode_strings';
|
||||
use PBot::Imports;
|
||||
|
||||
use DBI;
|
||||
use Carp qw(shortmess);
|
@ -9,8 +9,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::RelayUnreg;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::RelayUnreg;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -6,8 +6,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::RemindMe;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::RemindMe;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -9,8 +9,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::RestrictedMod;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::RestrictedMod;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -9,14 +9,14 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Spinach;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Spinach;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
use PBot::HashObject;
|
||||
|
||||
use Plugins::Spinach::Stats;
|
||||
use Plugins::Spinach::Rank;
|
||||
use PBot::Plugin::Spinach::Stats;
|
||||
use PBot::Plugin::Spinach::Rank;
|
||||
|
||||
use JSON;
|
||||
|
||||
@ -59,8 +59,8 @@ sub initialize {
|
||||
$self->{metadata}->load;
|
||||
$self->set_metadata_defaults;
|
||||
|
||||
$self->{stats} = Plugins::Spinach::Stats->new(pbot => $self->{pbot}, filename => $self->{stats_filename});
|
||||
$self->{rankcmd} = Plugins::Spinach::Rank->new(pbot => $self->{pbot}, channel => $self->{channel}, filename => $self->{stats_filename});
|
||||
$self->{stats} = PBot::Plugin::Spinach::Stats->new(pbot => $self->{pbot}, filename => $self->{stats_filename});
|
||||
$self->{rankcmd} = PBot::Plugin::Spinach::Rank->new(pbot => $self->{pbot}, channel => $self->{channel}, filename => $self->{stats_filename});
|
||||
|
||||
$self->create_states;
|
||||
$self->load_questions;
|
@ -5,17 +5,14 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Spinach::Rank;
|
||||
package PBot::Plugin::Spinach::Rank;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use feature 'unicode_strings';
|
||||
use PBot::Imports;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::RealBin/../../..";
|
||||
|
||||
use Plugins::Spinach::Stats;
|
||||
use PBot::Plugin::Spinach::Stats;
|
||||
use Math::Expression::Evaluator;
|
||||
|
||||
sub new {
|
||||
@ -31,7 +28,7 @@ sub initialize {
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{channel} = $conf{channel} // Carp::croak("Missing channel reference to " . __FILE__);
|
||||
$self->{filename} = $conf{filename} // 'stats.sqlite';
|
||||
$self->{stats} = Plugins::Spinach::Stats->new(pbot => $self->{pbot}, filename => $self->{filename});
|
||||
$self->{stats} = PBot::Plugin::Spinach::Stats->new(pbot => $self->{pbot}, filename => $self->{filename});
|
||||
}
|
||||
|
||||
sub sort_generic {
|
@ -5,12 +5,9 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Spinach::Stats;
|
||||
package PBot::Plugin::Spinach::Stats;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use feature 'unicode_strings';
|
||||
use PBot::Imports;
|
||||
|
||||
use DBI;
|
||||
use Carp qw(shortmess);
|
@ -15,8 +15,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::TypoSub;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::TypoSub;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::UrlTitles;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::UrlTitles;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Weather;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Weather;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Wolfram;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Wolfram;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
|
@ -5,8 +5,8 @@
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package Plugins::Wttr;
|
||||
use parent 'Plugins::Plugin';
|
||||
package PBot::Plugin::Wttr;
|
||||
use parent 'PBot::Plugin::Base';
|
||||
|
||||
use PBot::Imports;
|
||||
use PBot::Utils::LWPUserAgentCached;
|
@ -14,38 +14,51 @@ use File::Basename;
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
# loaded plugins
|
||||
$self->{plugins} = {};
|
||||
|
||||
# plugin management bot commands
|
||||
$self->{pbot}->{commands}->register(sub { $self->cmd_plug(@_) }, "plug", 1);
|
||||
$self->{pbot}->{commands}->register(sub { $self->cmd_unplug(@_) }, "unplug", 1);
|
||||
$self->{pbot}->{commands}->register(sub { $self->cmd_replug(@_) }, "replug", 1);
|
||||
$self->{pbot}->{commands}->register(sub { $self->cmd_pluglist(@_) }, "pluglist", 0);
|
||||
|
||||
# load configured plugins
|
||||
# autoload plugins listed in `$data_dir/plugins_autoload` file
|
||||
$self->autoload(%conf);
|
||||
}
|
||||
|
||||
sub cmd_plug {
|
||||
my ($self, $context) = @_;
|
||||
|
||||
my $plugin = $context->{arguments};
|
||||
|
||||
if (not length $plugin) { return "Usage: plug <plugin>"; }
|
||||
|
||||
if ($self->load($plugin)) { return "Loaded $plugin plugin."; }
|
||||
else { return "Plugin $plugin failed to load."; }
|
||||
if ($self->load($plugin)) {
|
||||
return "Loaded $plugin plugin.";
|
||||
} else {
|
||||
return "Plugin $plugin failed to load.";
|
||||
}
|
||||
}
|
||||
|
||||
sub cmd_unplug {
|
||||
my ($self, $context) = @_;
|
||||
|
||||
my $plugin = $context->{arguments};
|
||||
|
||||
if (not length $plugin) { return "Usage: unplug <plugin>"; }
|
||||
|
||||
if ($self->unload($plugin)) { return "Unloaded $plugin plugin."; }
|
||||
else { return "Plugin $plugin is not loaded."; }
|
||||
if ($self->unload($plugin)) {
|
||||
return "Unloaded $plugin plugin.";
|
||||
} else {
|
||||
return "Plugin $plugin is not loaded.";
|
||||
}
|
||||
}
|
||||
|
||||
sub cmd_replug {
|
||||
my ($self, $context) = @_;
|
||||
|
||||
my $plugin = $context->{arguments};
|
||||
|
||||
if (not length $plugin) { return "Usage: replug <plugin>"; }
|
||||
@ -53,7 +66,7 @@ sub cmd_replug {
|
||||
my $unload_result = $self->cmd_unplug($context);
|
||||
my $load_result = $self->cmd_plug($context);
|
||||
|
||||
my $result = "";
|
||||
my $result;
|
||||
$result .= "$unload_result " if $unload_result =~ m/^Unloaded/;
|
||||
$result .= $load_result;
|
||||
return $result;
|
||||
@ -71,12 +84,13 @@ sub cmd_pluglist {
|
||||
|
||||
sub autoload {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
return if $self->{pbot}->{registry}->get_value('plugins', 'noautoload');
|
||||
|
||||
my $path = $self->{pbot}->{registry}->get_value('general', 'plugin_dir') // 'Plugins';
|
||||
my $data_dir = $self->{pbot}->{registry}->get_value('general', 'data_dir');
|
||||
|
||||
$self->{pbot}->{logger}->log("Loading plugins ...\n");
|
||||
|
||||
my $plugin_count = 0;
|
||||
|
||||
my $fh;
|
||||
@ -84,7 +98,6 @@ sub autoload {
|
||||
$self->{pbot}->{logger}->log("warning: file $data_dir/plugin_autoload does not exist; skipping autoloading of Plugins\n");
|
||||
return;
|
||||
}
|
||||
|
||||
chomp(my @plugins = <$fh>);
|
||||
close $fh;
|
||||
|
||||
@ -97,6 +110,7 @@ sub autoload {
|
||||
$plugin =~ s/.pm$//;
|
||||
$plugin_count++ if $self->load($plugin, %conf);
|
||||
}
|
||||
|
||||
$self->{pbot}->{logger}->log("$plugin_count plugin" . ($plugin_count == 1 ? '' : 's') . " loaded.\n");
|
||||
}
|
||||
|
||||
@ -107,35 +121,31 @@ sub load {
|
||||
|
||||
return if $self->{pbot}->{registry}->get_value('plugins', 'disabled');
|
||||
|
||||
my $path = $self->{pbot}->{registry}->get_value('general', 'plugin_dir') // 'Plugins';
|
||||
my $module = "PBot/Plugin/$plugin.pm";
|
||||
|
||||
if (not grep { $_ eq $path } @INC) {
|
||||
unshift @INC, $path;
|
||||
}
|
||||
|
||||
$self->{pbot}->{refresher}->{refresher}->refresh_module("$path/$plugin.pm");
|
||||
$self->{pbot}->{refresher}->{refresher}->refresh_module($module);
|
||||
|
||||
my $ret = eval {
|
||||
require "$path/$plugin.pm";
|
||||
require "$module";
|
||||
|
||||
if ($@) {
|
||||
chomp $@;
|
||||
$self->{pbot}->{logger}->log("Error loading $plugin: $@\n");
|
||||
if (my $exception = $@) {
|
||||
$self->{pbot}->{logger}->log("Error loading $plugin: $exception");
|
||||
return 0;
|
||||
}
|
||||
|
||||
$self->{pbot}->{logger}->log("Loading $plugin\n");
|
||||
my $class = "Plugins::$plugin";
|
||||
|
||||
my $class = "PBot::Plugin::$plugin";
|
||||
$self->{plugins}->{$plugin} = $class->new(pbot => $self->{pbot}, %conf);
|
||||
$self->{pbot}->{refresher}->{refresher}->update_cache("$path/$plugin.pm");
|
||||
$self->{pbot}->{refresher}->{refresher}->update_cache($module);
|
||||
return 1;
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
chomp $@;
|
||||
$self->{pbot}->{logger}->log("Error loading $plugin: $@\n");
|
||||
if (my $exception = $@) {
|
||||
$self->{pbot}->{logger}->log("Error loading $plugin: $exception");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@ -147,18 +157,13 @@ sub unload {
|
||||
$self->{plugins}->{$plugin}->unload;
|
||||
delete $self->{plugins}->{$plugin};
|
||||
};
|
||||
if ($@) {
|
||||
chomp $@;
|
||||
$self->{pbot}->{logger}->log("Warning: got error unloading plugin $plugin: $@\n");
|
||||
|
||||
if (my $exception = $@) {
|
||||
$self->{pbot}->{logger}->log("Warning: got error unloading plugin $plugin: $exception");
|
||||
}
|
||||
|
||||
my $path = $self->{pbot}->{registry}->get_value('general', 'plugin_dir') // 'Plugins';
|
||||
my $class = $path;
|
||||
$class =~ s,[/\\],::,g;
|
||||
|
||||
$self->{pbot}->{refresher}->{refresher}->unload_module($class . '::' . $plugin);
|
||||
$self->{pbot}->{refresher}->{refresher}->unload_subs("$path/$plugin.pm");
|
||||
|
||||
my $module = "PBot/Plugin/$plugin.pm";
|
||||
$self->{pbot}->{refresher}->{refresher}->unload_module($module);
|
||||
$self->{pbot}->{logger}->log("Plugin $plugin unloaded.\n");
|
||||
return 1;
|
||||
} else {
|
4
misc/update-version
vendored
4
misc/update-version
vendored
@ -22,11 +22,11 @@ $rev++;
|
||||
|
||||
print "New version: $rev $date\n";
|
||||
|
||||
open my $in, '<', "PBot/VERSION.pm" or die "Couldn't open VERSION.pm for reading: $!";
|
||||
open my $in, '<', "lib/PBot/VERSION.pm" or die "Couldn't open VERSION.pm for reading: $!";
|
||||
my @lines = <$in>;
|
||||
close $in;
|
||||
|
||||
open my $out, '>', "PBot/VERSION.pm" or die "Couldn't open VERSION.pm for writing: $!";
|
||||
open my $out, '>', "lib/PBot/VERSION.pm" or die "Couldn't open VERSION.pm for writing: $!";
|
||||
|
||||
foreach my $text (@lines) {
|
||||
$text =~ s/BUILD_NAME\s+=> ".*",/BUILD_NAME => "PBot",/;
|
||||
|
22
pbot
22
pbot
@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# File: pbot
|
||||
#
|
||||
# Purpose: PBot main entry point. See doc/QuickStart.md.
|
||||
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/";
|
||||
|
||||
use PBot::PBot;
|
||||
|
||||
PBot::PBot->new(
|
||||
# configuration is overridden via command-line arguments.
|
||||
# do not modify these values. see doc/QuickStart.md
|
||||
data_dir => "$RealBin/data",
|
||||
module_dir => "$RealBin/modules",
|
||||
plugin_dir => "$RealBin/Plugins",
|
||||
update_dir => "$RealBin/updates",
|
||||
)->start;
|
20
script/pbot
Executable file
20
script/pbot
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# File: pbot
|
||||
#
|
||||
# Purpose: PBot main entry point. See doc/QuickStart.md.
|
||||
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
use FindBin qw($Bin);
|
||||
use lib "$Bin/../lib";
|
||||
use lib "$ENV{HOME}/.pbot";
|
||||
|
||||
use PBot::PBot;
|
||||
|
||||
PBot::PBot->new(
|
||||
data_dir => "$Bin/../data",
|
||||
module_dir => "$Bin/../modules",
|
||||
update_dir => "$Bin/../updates",
|
||||
)->start;
|
@ -14,6 +14,11 @@ my ($data_dir, $version, $last_update) = @ARGV;
|
||||
|
||||
print "Updating message history database... version: $version, last_update: $last_update, data_dir: $data_dir\n";
|
||||
|
||||
if (not -e "$data_dir/message_history.sqlite3") {
|
||||
print "$data_dir/message_history.sqlite3 does not exist; skipping update.\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
use DBI;
|
||||
|
||||
my $dbh = DBI->connect("dbi:SQLite:dbname=$data_dir/message_history.sqlite3", "", "", {RaiseError => 1, PrintError => 0, AutoInactiveDestroy => 1, sqlite_unicode => 1})
|
||||
|
Loading…
Reference in New Issue
Block a user