mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-15 00:19:31 +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
|
# 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
|
# however, it does use the ancient but simple Net::IRC package (if it
|
||||||
# ain't broke) instead of packages based on significantly more complex
|
# ain't broke) instead of packages based on significantly more complex
|
||||||
# Enterprise-level event-loop frameworks. PBot uses pure Perl 5 blessed
|
# Enterprise-level event-loop frameworks. PBot uses pure Perl 5 blessed
|
||||||
@ -89,7 +89,6 @@ sub initialize {
|
|||||||
$value =~ s/[\\\/]$//; # strip trailing directory separator
|
$value =~ s/[\\\/]$//; # strip trailing directory separator
|
||||||
$conf{data_dir} = $value if $override eq 'data_dir';
|
$conf{data_dir} = $value if $override eq 'data_dir';
|
||||||
$conf{module_dir} = $value if $override eq 'module_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';
|
$conf{update_dir} = $value if $override eq 'update_dir';
|
||||||
} else {
|
} else {
|
||||||
# check command-line arguments for registry overrides
|
# check command-line arguments for registry overrides
|
||||||
@ -113,7 +112,7 @@ sub initialize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# make sure the paths exist
|
# 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}) {
|
if (not -d $conf{$path}) {
|
||||||
print STDERR "$path path ($conf{$path}) does not exist; aborting.\n";
|
print STDERR "$path path ($conf{$path}) does not exist; aborting.\n";
|
||||||
exit;
|
exit;
|
||||||
@ -140,7 +139,6 @@ sub initialize {
|
|||||||
|
|
||||||
# log configured paths
|
# log configured paths
|
||||||
$self->{logger}->log("module_dir: $conf{module_dir}\n");
|
$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(" data_dir: $conf{data_dir}\n");
|
||||||
$self->{logger}->log("update_dir: $conf{update_dir}\n");
|
$self->{logger}->log("update_dir: $conf{update_dir}\n");
|
||||||
|
|
@ -34,8 +34,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::ActionTrigger;
|
package PBot::Plugin::ActionTrigger;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::AntiAway;
|
package PBot::Plugin::AntiAway;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::AntiKickAutoRejoin;
|
package PBot::Plugin::AntiKickAutoRejoin;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -6,8 +6,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::AntiNickSpam;
|
package PBot::Plugin::AntiNickSpam;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::AntiRepeat;
|
package PBot::Plugin::AntiRepeat;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -6,8 +6,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::AntiTwitter;
|
package PBot::Plugin::AntiTwitter;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::AutoRejoin;
|
package PBot::Plugin::AutoRejoin;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use Time::HiRes qw/gettimeofday/;
|
use Time::HiRes qw/gettimeofday/;
|
||||||
use Time::Duration;
|
use Time::Duration;
|
@ -1,11 +1,11 @@
|
|||||||
# File: Plugin.pm
|
# File: Base.pm
|
||||||
#
|
#
|
||||||
# Purpose: Base class for PBot plugins.
|
# Purpose: Base class for PBot plugins.
|
||||||
|
|
||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Plugin;
|
package PBot::Plugin::Base;
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -24,8 +24,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Battleship;
|
package PBot::Plugin::Battleship;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -6,8 +6,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Connect4;
|
package PBot::Plugin::Connect4;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -6,8 +6,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Counter;
|
package PBot::Plugin::Counter;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Date;
|
package PBot::Plugin::Date;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Example;
|
package PBot::Plugin::Example;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::FuncBuiltins;
|
package PBot::Plugin::FuncBuiltins;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::FuncGrep;
|
package PBot::Plugin::FuncGrep;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::FuncPlural;
|
package PBot::Plugin::FuncPlural;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::FuncSed;
|
package PBot::Plugin::FuncSed;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -6,8 +6,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::GoogleSearch;
|
package PBot::Plugin::GoogleSearch;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -6,8 +6,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::ParseDate;
|
package PBot::Plugin::ParseDate;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -6,8 +6,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Plang;
|
package PBot::Plugin::Plang;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -8,8 +8,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Quotegrabs;
|
package PBot::Plugin::Quotegrabs;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
||||||
@ -18,9 +18,8 @@ use Time::Duration;
|
|||||||
use Time::HiRes qw(gettimeofday);
|
use Time::HiRes qw(gettimeofday);
|
||||||
use Getopt::Long qw(GetOptionsFromArray);
|
use Getopt::Long qw(GetOptionsFromArray);
|
||||||
|
|
||||||
use Plugins::Quotegrabs::Quotegrabs_SQLite; # use SQLite 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 Plugins::Quotegrabs::Quotegrabs_Hashtable; # use Perl hashtable backend for quotegrabs database
|
|
||||||
use PBot::Utils::ValidateString;
|
use PBot::Utils::ValidateString;
|
||||||
|
|
||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
@ -29,9 +28,8 @@ sub initialize {
|
|||||||
my ($self, %conf) = @_;
|
my ($self, %conf) = @_;
|
||||||
$self->{filename} = $conf{quotegrabs_file} // $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/quotegrabs.sqlite3';
|
$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} = 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} = Plugins::Quotegrabs::Quotegrabs_Hashtable->new(pbot => $self->{pbot}, filename => $self->{filename});
|
|
||||||
$self->{database}->begin();
|
$self->{database}->begin();
|
||||||
|
|
||||||
$self->{pbot}->{atexit}->register(sub { $self->{database}->end(); return; });
|
$self->{pbot}->{atexit}->register(sub { $self->{database}->end(); return; });
|
@ -5,12 +5,9 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Quotegrabs::Quotegrabs_Hashtable;
|
package PBot::Plugin::Quotegrabs::Quotegrabs_Hashtable;
|
||||||
|
|
||||||
use warnings;
|
use PBot::Imports;
|
||||||
use strict;
|
|
||||||
|
|
||||||
use feature 'unicode_strings';
|
|
||||||
|
|
||||||
use HTML::Entities;
|
use HTML::Entities;
|
||||||
use Time::Duration;
|
use Time::Duration;
|
@ -5,12 +5,9 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Quotegrabs::Quotegrabs_SQLite;
|
package PBot::Plugin::Quotegrabs::Quotegrabs_SQLite;
|
||||||
|
|
||||||
use warnings;
|
use PBot::Imports;
|
||||||
use strict;
|
|
||||||
|
|
||||||
use feature 'unicode_strings';
|
|
||||||
|
|
||||||
use DBI;
|
use DBI;
|
||||||
use Carp qw(shortmess);
|
use Carp qw(shortmess);
|
@ -9,8 +9,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::RelayUnreg;
|
package PBot::Plugin::RelayUnreg;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -6,8 +6,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::RemindMe;
|
package PBot::Plugin::RemindMe;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -9,8 +9,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::RestrictedMod;
|
package PBot::Plugin::RestrictedMod;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -9,14 +9,14 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Spinach;
|
package PBot::Plugin::Spinach;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
use PBot::HashObject;
|
use PBot::HashObject;
|
||||||
|
|
||||||
use Plugins::Spinach::Stats;
|
use PBot::Plugin::Spinach::Stats;
|
||||||
use Plugins::Spinach::Rank;
|
use PBot::Plugin::Spinach::Rank;
|
||||||
|
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
@ -59,8 +59,8 @@ sub initialize {
|
|||||||
$self->{metadata}->load;
|
$self->{metadata}->load;
|
||||||
$self->set_metadata_defaults;
|
$self->set_metadata_defaults;
|
||||||
|
|
||||||
$self->{stats} = Plugins::Spinach::Stats->new(pbot => $self->{pbot}, filename => $self->{stats_filename});
|
$self->{stats} = PBot::Plugin::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->{rankcmd} = PBot::Plugin::Spinach::Rank->new(pbot => $self->{pbot}, channel => $self->{channel}, filename => $self->{stats_filename});
|
||||||
|
|
||||||
$self->create_states;
|
$self->create_states;
|
||||||
$self->load_questions;
|
$self->load_questions;
|
@ -5,17 +5,14 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Spinach::Rank;
|
package PBot::Plugin::Spinach::Rank;
|
||||||
|
|
||||||
use warnings;
|
use PBot::Imports;
|
||||||
use strict;
|
|
||||||
|
|
||||||
use feature 'unicode_strings';
|
|
||||||
|
|
||||||
use FindBin;
|
use FindBin;
|
||||||
use lib "$FindBin::RealBin/../../..";
|
use lib "$FindBin::RealBin/../../..";
|
||||||
|
|
||||||
use Plugins::Spinach::Stats;
|
use PBot::Plugin::Spinach::Stats;
|
||||||
use Math::Expression::Evaluator;
|
use Math::Expression::Evaluator;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -31,7 +28,7 @@ sub initialize {
|
|||||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||||
$self->{channel} = $conf{channel} // Carp::croak("Missing channel reference to " . __FILE__);
|
$self->{channel} = $conf{channel} // Carp::croak("Missing channel reference to " . __FILE__);
|
||||||
$self->{filename} = $conf{filename} // 'stats.sqlite';
|
$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 {
|
sub sort_generic {
|
@ -5,12 +5,9 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Spinach::Stats;
|
package PBot::Plugin::Spinach::Stats;
|
||||||
|
|
||||||
use warnings;
|
use PBot::Imports;
|
||||||
use strict;
|
|
||||||
|
|
||||||
use feature 'unicode_strings';
|
|
||||||
|
|
||||||
use DBI;
|
use DBI;
|
||||||
use Carp qw(shortmess);
|
use Carp qw(shortmess);
|
@ -15,8 +15,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::TypoSub;
|
package PBot::Plugin::TypoSub;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::UrlTitles;
|
package PBot::Plugin::UrlTitles;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Weather;
|
package PBot::Plugin::Weather;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Wolfram;
|
package PBot::Plugin::Wolfram;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
|
|
@ -5,8 +5,8 @@
|
|||||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package Plugins::Wttr;
|
package PBot::Plugin::Wttr;
|
||||||
use parent 'Plugins::Plugin';
|
use parent 'PBot::Plugin::Base';
|
||||||
|
|
||||||
use PBot::Imports;
|
use PBot::Imports;
|
||||||
use PBot::Utils::LWPUserAgentCached;
|
use PBot::Utils::LWPUserAgentCached;
|
@ -14,38 +14,51 @@ use File::Basename;
|
|||||||
|
|
||||||
sub initialize {
|
sub initialize {
|
||||||
my ($self, %conf) = @_;
|
my ($self, %conf) = @_;
|
||||||
|
|
||||||
|
# loaded plugins
|
||||||
$self->{plugins} = {};
|
$self->{plugins} = {};
|
||||||
|
|
||||||
|
# plugin management bot commands
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_plug(@_) }, "plug", 1);
|
$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_unplug(@_) }, "unplug", 1);
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_replug(@_) }, "replug", 1);
|
$self->{pbot}->{commands}->register(sub { $self->cmd_replug(@_) }, "replug", 1);
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_pluglist(@_) }, "pluglist", 0);
|
$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);
|
$self->autoload(%conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub cmd_plug {
|
sub cmd_plug {
|
||||||
my ($self, $context) = @_;
|
my ($self, $context) = @_;
|
||||||
|
|
||||||
my $plugin = $context->{arguments};
|
my $plugin = $context->{arguments};
|
||||||
|
|
||||||
if (not length $plugin) { return "Usage: plug <plugin>"; }
|
if (not length $plugin) { return "Usage: plug <plugin>"; }
|
||||||
|
|
||||||
if ($self->load($plugin)) { return "Loaded $plugin plugin."; }
|
if ($self->load($plugin)) {
|
||||||
else { return "Plugin $plugin failed to load."; }
|
return "Loaded $plugin plugin.";
|
||||||
|
} else {
|
||||||
|
return "Plugin $plugin failed to load.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub cmd_unplug {
|
sub cmd_unplug {
|
||||||
my ($self, $context) = @_;
|
my ($self, $context) = @_;
|
||||||
|
|
||||||
my $plugin = $context->{arguments};
|
my $plugin = $context->{arguments};
|
||||||
|
|
||||||
if (not length $plugin) { return "Usage: unplug <plugin>"; }
|
if (not length $plugin) { return "Usage: unplug <plugin>"; }
|
||||||
|
|
||||||
if ($self->unload($plugin)) { return "Unloaded $plugin plugin."; }
|
if ($self->unload($plugin)) {
|
||||||
else { return "Plugin $plugin is not loaded."; }
|
return "Unloaded $plugin plugin.";
|
||||||
|
} else {
|
||||||
|
return "Plugin $plugin is not loaded.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub cmd_replug {
|
sub cmd_replug {
|
||||||
my ($self, $context) = @_;
|
my ($self, $context) = @_;
|
||||||
|
|
||||||
my $plugin = $context->{arguments};
|
my $plugin = $context->{arguments};
|
||||||
|
|
||||||
if (not length $plugin) { return "Usage: replug <plugin>"; }
|
if (not length $plugin) { return "Usage: replug <plugin>"; }
|
||||||
@ -53,7 +66,7 @@ sub cmd_replug {
|
|||||||
my $unload_result = $self->cmd_unplug($context);
|
my $unload_result = $self->cmd_unplug($context);
|
||||||
my $load_result = $self->cmd_plug($context);
|
my $load_result = $self->cmd_plug($context);
|
||||||
|
|
||||||
my $result = "";
|
my $result;
|
||||||
$result .= "$unload_result " if $unload_result =~ m/^Unloaded/;
|
$result .= "$unload_result " if $unload_result =~ m/^Unloaded/;
|
||||||
$result .= $load_result;
|
$result .= $load_result;
|
||||||
return $result;
|
return $result;
|
||||||
@ -71,12 +84,13 @@ sub cmd_pluglist {
|
|||||||
|
|
||||||
sub autoload {
|
sub autoload {
|
||||||
my ($self, %conf) = @_;
|
my ($self, %conf) = @_;
|
||||||
|
|
||||||
return if $self->{pbot}->{registry}->get_value('plugins', 'noautoload');
|
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');
|
my $data_dir = $self->{pbot}->{registry}->get_value('general', 'data_dir');
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("Loading plugins ...\n");
|
$self->{pbot}->{logger}->log("Loading plugins ...\n");
|
||||||
|
|
||||||
my $plugin_count = 0;
|
my $plugin_count = 0;
|
||||||
|
|
||||||
my $fh;
|
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");
|
$self->{pbot}->{logger}->log("warning: file $data_dir/plugin_autoload does not exist; skipping autoloading of Plugins\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chomp(my @plugins = <$fh>);
|
chomp(my @plugins = <$fh>);
|
||||||
close $fh;
|
close $fh;
|
||||||
|
|
||||||
@ -97,6 +110,7 @@ sub autoload {
|
|||||||
$plugin =~ s/.pm$//;
|
$plugin =~ s/.pm$//;
|
||||||
$plugin_count++ if $self->load($plugin, %conf);
|
$plugin_count++ if $self->load($plugin, %conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("$plugin_count plugin" . ($plugin_count == 1 ? '' : 's') . " loaded.\n");
|
$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');
|
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) {
|
$self->{pbot}->{refresher}->{refresher}->refresh_module($module);
|
||||||
unshift @INC, $path;
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{pbot}->{refresher}->{refresher}->refresh_module("$path/$plugin.pm");
|
|
||||||
|
|
||||||
my $ret = eval {
|
my $ret = eval {
|
||||||
require "$path/$plugin.pm";
|
require "$module";
|
||||||
|
|
||||||
if ($@) {
|
if (my $exception = $@) {
|
||||||
chomp $@;
|
$self->{pbot}->{logger}->log("Error loading $plugin: $exception");
|
||||||
$self->{pbot}->{logger}->log("Error loading $plugin: $@\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("Loading $plugin\n");
|
$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->{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;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($@) {
|
if (my $exception = $@) {
|
||||||
chomp $@;
|
$self->{pbot}->{logger}->log("Error loading $plugin: $exception");
|
||||||
$self->{pbot}->{logger}->log("Error loading $plugin: $@\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,18 +157,13 @@ sub unload {
|
|||||||
$self->{plugins}->{$plugin}->unload;
|
$self->{plugins}->{$plugin}->unload;
|
||||||
delete $self->{plugins}->{$plugin};
|
delete $self->{plugins}->{$plugin};
|
||||||
};
|
};
|
||||||
if ($@) {
|
|
||||||
chomp $@;
|
if (my $exception = $@) {
|
||||||
$self->{pbot}->{logger}->log("Warning: got error unloading plugin $plugin: $@\n");
|
$self->{pbot}->{logger}->log("Warning: got error unloading plugin $plugin: $exception");
|
||||||
}
|
}
|
||||||
|
|
||||||
my $path = $self->{pbot}->{registry}->get_value('general', 'plugin_dir') // 'Plugins';
|
my $module = "PBot/Plugin/$plugin.pm";
|
||||||
my $class = $path;
|
$self->{pbot}->{refresher}->{refresher}->unload_module($module);
|
||||||
$class =~ s,[/\\],::,g;
|
|
||||||
|
|
||||||
$self->{pbot}->{refresher}->{refresher}->unload_module($class . '::' . $plugin);
|
|
||||||
$self->{pbot}->{refresher}->{refresher}->unload_subs("$path/$plugin.pm");
|
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("Plugin $plugin unloaded.\n");
|
$self->{pbot}->{logger}->log("Plugin $plugin unloaded.\n");
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
4
misc/update-version
vendored
4
misc/update-version
vendored
@ -22,11 +22,11 @@ $rev++;
|
|||||||
|
|
||||||
print "New version: $rev $date\n";
|
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>;
|
my @lines = <$in>;
|
||||||
close $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) {
|
foreach my $text (@lines) {
|
||||||
$text =~ s/BUILD_NAME\s+=> ".*",/BUILD_NAME => "PBot",/;
|
$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";
|
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;
|
use DBI;
|
||||||
|
|
||||||
my $dbh = DBI->connect("dbi:SQLite:dbname=$data_dir/message_history.sqlite3", "", "", {RaiseError => 1, PrintError => 0, AutoInactiveDestroy => 1, sqlite_unicode => 1})
|
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