From 17e4cdb8b31b97fef8d03648b25c6a22073edb6d Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 8 Sep 2015 11:42:43 -0700 Subject: [PATCH] Move Quotegrabs to Plugins --- PBot/BotAdminCommands.pm | 6 +---- PBot/PBot.pm | 9 -------- PBot/{ => Plugins}/Quotegrabs.pm | 23 +++++++------------ .../Quotegrabs}/Quotegrabs_Hashtable.pm | 0 .../Quotegrabs}/Quotegrabs_SQLite.pm | 0 5 files changed, 9 insertions(+), 29 deletions(-) rename PBot/{ => Plugins}/Quotegrabs.pm (92%) rename PBot/{ => Plugins/Quotegrabs}/Quotegrabs_Hashtable.pm (100%) rename PBot/{ => Plugins/Quotegrabs}/Quotegrabs_SQLite.pm (100%) diff --git a/PBot/BotAdminCommands.pm b/PBot/BotAdminCommands.pm index c05c52ca..4d671094 100644 --- a/PBot/BotAdminCommands.pm +++ b/PBot/BotAdminCommands.pm @@ -221,17 +221,13 @@ sub export { my ($from, $nick, $user, $host, $arguments) = @_; if(not defined $arguments) { - return "/msg $nick Usage: export "; + return "/msg $nick Usage: export "; } if($arguments =~ /^modules$/i) { return "/msg $nick Coming soon."; } - if($arguments =~ /^quotegrabs$/i) { - return $self->{pbot}->{quotegrabs}->export_quotegrabs; - } - if($arguments =~ /^factoids$/i) { return $self->{pbot}->{factoids}->export_factoids; } diff --git a/PBot/PBot.pm b/PBot/PBot.pm index 4a9e8f21..3cbf58a4 100644 --- a/PBot/PBot.pm +++ b/PBot/PBot.pm @@ -45,7 +45,6 @@ use PBot::Factoids; use PBot::BotAdmins; use PBot::IgnoreList; use PBot::BlackList; -use PBot::Quotegrabs; use PBot::Timer; use PBot::Refresher; use PBot::Plugins; @@ -133,14 +132,6 @@ sub initialize { %conf ); - $self->{quotegrabs} = PBot::Quotegrabs->new( - pbot => $self, - filename => delete $conf{quotegrabs_file}, - export_path => delete $conf{export_quotegrabs_path}, - export_site => delete $conf{export_quotegrabs_site}, - %conf - ); - $self->{plugins} = PBot::Plugins->new(pbot => $self, %conf); # load registry entries from file to overwrite defaults diff --git a/PBot/Quotegrabs.pm b/PBot/Plugins/Quotegrabs.pm similarity index 92% rename from PBot/Quotegrabs.pm rename to PBot/Plugins/Quotegrabs.pm index 60c777ca..d8ee4925 100644 --- a/PBot/Quotegrabs.pm +++ b/PBot/Plugins/Quotegrabs.pm @@ -3,7 +3,7 @@ # # Purpose: Allows users to "grab" quotes from anti-flood history and store them for later retreival. -package PBot::Quotegrabs; +package PBot::Plugins::Quotegrabs; use warnings; use strict; @@ -13,8 +13,8 @@ use Time::Duration; use Time::HiRes qw(gettimeofday); use Getopt::Long qw(GetOptionsFromString); -use PBot::Quotegrabs_SQLite; # use SQLite backend for quotegrabs database -#use PBot::Quotegrabs_Hashtable; # use Perl hashtable backend for quotegrabs database +use PBot::Plugins::Quotegrabs::Quotegrabs_SQLite; # use SQLite backend for quotegrabs database +#use PBot::Plugins::Quotegrabs::Quotegrabs_Hashtable; # use Perl hashtable backend for quotegrabs database use POSIX qw(strftime); @@ -33,10 +33,10 @@ sub new { sub initialize { my ($self, %conf) = @_; - $self->{pbot} = delete $conf{pbot} // Carp::croak("Missing pbot reference in Quotegrabs"); - $self->{filename} = delete $conf{filename}; - $self->{export_path} = delete $conf{export_path}; - $self->{export_site} = delete $conf{export_site}; + $self->{pbot} = delete $conf{pbot} // Carp::croak("Missing pbot reference in Quotegrabs"); + $self->{filename} = delete $conf{quotegrabs_file}; + $self->{export_path} = delete $conf{export_quotegrabs_path}; + $self->{export_site} = delete $conf{export_quotegrabs_site}; $self->{database} = PBot::Quotegrabs_SQLite->new(pbot => $self->{pbot}, filename => $self->{filename}); #$self->{database} = PBot::Quotegrabs_Hashtable->new(pbot => $self->{pbot}, filename => $self->{filename}); @@ -44,9 +44,6 @@ sub initialize { $self->{pbot}->{atexit}->register(sub { $self->{database}->end(); return; }); - #------------------------------------------------------------------------------------- - # The following could be in QuotegrabsCommands.pm, or they could be kept in here? - #------------------------------------------------------------------------------------- $self->{pbot}->{commands}->register(sub { $self->grab_quotegrab(@_) }, "grab", 0); $self->{pbot}->{commands}->register(sub { $self->show_quotegrab(@_) }, "getq", 0); $self->{pbot}->{commands}->register(sub { $self->delete_quotegrab(@_) }, "delq", 0); @@ -57,7 +54,7 @@ sub uniq { my %seen; grep !$seen{$_}++, @_ } sub export_quotegrabs { my $self = shift; - return "Not enabled" if not defined $self->{export_path}; + return "Quotegrabs exporting not enabled." if not defined $self->{export_path}; my $quotegrabs = $self->{database}->get_all_quotegrabs(); @@ -148,10 +145,6 @@ sub export_quotegrabs { return "$i quotegrabs exported to " . $self->{export_site}; } -# ---------------------------------------------------------------------------------------- -# The following subroutines could be in QuotegrabCommands.pm . . . -# ---------------------------------------------------------------------------------------- - sub grab_quotegrab { my ($self, $from, $nick, $user, $host, $arguments) = @_; diff --git a/PBot/Quotegrabs_Hashtable.pm b/PBot/Plugins/Quotegrabs/Quotegrabs_Hashtable.pm similarity index 100% rename from PBot/Quotegrabs_Hashtable.pm rename to PBot/Plugins/Quotegrabs/Quotegrabs_Hashtable.pm diff --git a/PBot/Quotegrabs_SQLite.pm b/PBot/Plugins/Quotegrabs/Quotegrabs_SQLite.pm similarity index 100% rename from PBot/Quotegrabs_SQLite.pm rename to PBot/Plugins/Quotegrabs/Quotegrabs_SQLite.pm