mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 22:09:26 +01:00
Move Quotegrabs to Plugins
This commit is contained in:
parent
de2774ed00
commit
17e4cdb8b3
@ -221,17 +221,13 @@ sub export {
|
||||
my ($from, $nick, $user, $host, $arguments) = @_;
|
||||
|
||||
if(not defined $arguments) {
|
||||
return "/msg $nick Usage: export <modules|factoids|admins|quotegrabs>";
|
||||
return "/msg $nick Usage: export <modules|factoids|admins>";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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) = @_;
|
||||
|
Loading…
Reference in New Issue
Block a user