mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 05:49:27 +01:00
Plugins: use Plugin parent class
This commit is contained in:
parent
e58044f2f1
commit
59af6e944d
@ -3,6 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::ActionTrigger;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
# purpose: provides interface to set/remove/modify regular expression triggers
|
||||
# to execute a command.
|
||||
@ -26,31 +27,18 @@ package Plugins::ActionTrigger;
|
||||
#
|
||||
# These are basic examples; more complex examples can be crafted.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use feature 'switch';
|
||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
use Carp ();
|
||||
use DBI;
|
||||
use Time::Duration qw/duration/;
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{commands}->register(sub { $self->actiontrigger(@_) }, 'actiontrigger', 1);
|
||||
$self->{pbot}->{capabilities}->add('admin', 'can-actiontrigger', 1);
|
||||
|
||||
|
@ -8,26 +8,13 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::AntiAway;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{registry}->add_default('text', 'antiaway', 'bad_nicks', $conf{bad_nicks} // '([[:punct:]](afk|brb|bbl|away|sleep|z+|work|gone|study|out|home|busy|off)[[:punct:]]*$|.+\[.*\]$)');
|
||||
$self->{pbot}->{registry}->add_default('text', 'antiaway', 'bad_actions', $conf{bad_actions} // '^/me (is (away|gone)|.*auto.?away)');
|
||||
$self->{pbot}->{registry}->add_default('text', 'antiaway', 'kick_msg', 'http://sackheads.org/~bnaylor/spew/away_msgs.html');
|
||||
|
@ -8,28 +8,16 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::AntiKickAutoRejoin;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
use Time::Duration;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{registry}->add_default('array', 'antikickautorejoin', 'punishment', '300,900,1800,3600,28800');
|
||||
$self->{pbot}->{registry}->add_default('text', 'antikickautorejoin', 'threshold', '4');
|
||||
|
||||
|
@ -9,27 +9,16 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::AntiNickSpam;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
use Time::Duration qw/duration/;
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.public', sub { $self->on_public(@_) });
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.caction', sub { $self->on_action(@_) });
|
||||
$self->{nicks} = {};
|
||||
@ -61,7 +50,6 @@ sub on_public {
|
||||
|
||||
sub check_flood {
|
||||
my ($self, $nick, $user, $host, $channel, $msg) = @_;
|
||||
|
||||
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
||||
|
||||
$channel = lc $channel;
|
||||
@ -86,9 +74,7 @@ sub check_flood {
|
||||
|
||||
sub clear_old_nicks {
|
||||
my ($self, $channel) = @_;
|
||||
|
||||
my $now = gettimeofday;
|
||||
|
||||
return if not exists $self->{nicks}->{$channel};
|
||||
|
||||
while (1) {
|
||||
|
@ -3,33 +3,20 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::AntiRepeat;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use feature 'switch';
|
||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
|
||||
use String::LCSS qw/lcss/;
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
use POSIX qw/strftime/;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{registry}->add_default('text', 'antiflood', 'antirepeat', $conf{antirepeat} // 1);
|
||||
$self->{pbot}->{registry}->add_default('text', 'antiflood', 'antirepeat_threshold', $conf{antirepeat_threshold} // 2.5);
|
||||
$self->{pbot}->{registry}->add_default('text', 'antiflood', 'antirepeat_match', $conf{antirepeat_match} // 0.5);
|
||||
|
@ -9,30 +9,19 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::AntiTwitter;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
use Time::Duration qw/duration/;
|
||||
|
||||
use feature 'switch';
|
||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.public', sub { $self->on_public(@_) });
|
||||
$self->{pbot}->{timer}->register(sub { $self->adjust_offenses }, 60 * 60 * 1, 'antitwitter');
|
||||
$self->{offenses} = {};
|
||||
|
@ -8,30 +8,17 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::AutoRejoin;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
use Time::Duration;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{registry}->add_default('array', 'autorejoin', 'rejoin_delay', '900,1800,3600');
|
||||
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.kick', sub { $self->on_kick(@_) });
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.part', sub { $self->on_part(@_) });
|
||||
$self->{rejoins} = {};
|
||||
|
@ -3,34 +3,22 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Battleship;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
use utf8;
|
||||
|
||||
use feature 'switch';
|
||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
use feature 'unicode_strings';
|
||||
use utf8;
|
||||
|
||||
use Carp ();
|
||||
use Time::Duration qw/concise duration/;
|
||||
use Data::Dumper;
|
||||
$Data::Dumper::Useqq = 1;
|
||||
$Data::Dumper::Sortkeys = 1;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{commands}->register(sub { $self->battleship_cmd(@_) }, 'battleship', 0);
|
||||
|
||||
$self->{pbot}->{timer}->register(sub { $self->battleship_timer }, 1, 'battleship timer');
|
||||
|
@ -3,34 +3,22 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Connect4;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use feature 'switch';
|
||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
use Time::Duration qw/concise duration/;
|
||||
use Data::Dumper;
|
||||
use List::Util qw[min max];
|
||||
$Data::Dumper::Useqq = 1;
|
||||
$Data::Dumper::Sortkeys = 1;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot};
|
||||
|
||||
$self->{pbot}->{commands}->register(sub { $self->connect4_cmd(@_) }, 'connect4', 0);
|
||||
|
||||
$self->{pbot}->{timer}->register(sub { $self->connect4_timer }, 1, 'connect4 timer');
|
||||
|
@ -3,32 +3,20 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Counter;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use feature 'switch';
|
||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
use DBI;
|
||||
use Time::Duration qw/duration/;
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{commands}->register(sub { $self->counteradd(@_) }, 'counteradd', 0);
|
||||
$self->{pbot}->{commands}->register(sub { $self->counterdel(@_) }, 'counterdel', 0);
|
||||
$self->{pbot}->{commands}->register(sub { $self->counterreset(@_) }, 'counterreset', 0);
|
||||
|
@ -8,26 +8,16 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Date;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Getopt::Long qw(GetOptionsFromString);
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
Getopt::Long::Configure("bundling");
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{registry}->add_default('text', 'date', 'default_timezone', 'UTC');
|
||||
$self->{pbot}->{commands}->register(sub { $self->datecmd(@_) }, "date", 0);
|
||||
}
|
||||
@ -39,10 +29,7 @@ sub unload {
|
||||
|
||||
sub datecmd {
|
||||
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
|
||||
my $usage = "date [-u <user account>] [timezone]";
|
||||
Getopt::Long::Configure("bundling");
|
||||
|
||||
my $getopt_error;
|
||||
local $SIG{__WARN__} = sub {
|
||||
$getopt_error = shift;
|
||||
|
@ -3,24 +3,13 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Example;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.public', sub { $self->on_public(@_) });
|
||||
}
|
||||
|
||||
|
@ -5,29 +5,16 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::GoogleSearch;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use WWW::Google::CustomSearch;
|
||||
use HTML::Entities;
|
||||
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{registry}->add_default('text', 'googlesearch', 'api_key', '');
|
||||
$self->{pbot}->{registry}->add_default('text', 'googlesearch', 'context', '');
|
||||
|
||||
@ -44,16 +31,10 @@ sub unload {
|
||||
|
||||
sub googlesearch {
|
||||
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
|
||||
if (not length $arguments) {
|
||||
return "Usage: google [number of results] query\n";
|
||||
}
|
||||
return "Usage: google [number of results] query\n" if not length $arguments;
|
||||
|
||||
my $matches = 1;
|
||||
|
||||
if ($arguments =~ s/^([0-9]+)//) {
|
||||
$matches = $1;
|
||||
}
|
||||
$matches = $1 if $arguments =~ s/^-n\s+([0-9]+)\s*//;
|
||||
|
||||
my $api_key = $self->{pbot}->{registry}->get_value('googlesearch', 'api_key'); # https://developers.google.com/custom-search/v1/overview
|
||||
my $cx = $self->{pbot}->{registry}->get_value('googlesearch', 'context'); # https://cse.google.com/all
|
||||
|
@ -8,24 +8,13 @@
|
||||
# command).
|
||||
|
||||
package Plugins::MagicCommand;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{commands}->register(sub { return $self->magic(@_)}, "mc", 90);
|
||||
}
|
||||
|
||||
|
@ -5,26 +5,15 @@
|
||||
# Just a quick interface to test/play with PBot::Utils::ParseDate
|
||||
|
||||
package Plugins::ParseDate;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
use Carp ();
|
||||
|
||||
use Time::Duration qw/duration/;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{commands}->register(sub { return $self->pd(@_)}, "pd", 0);
|
||||
}
|
||||
|
||||
|
39
Plugins/Plugin.pm
Normal file
39
Plugins/Plugin.pm
Normal file
@ -0,0 +1,39 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# 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::Plugin;
|
||||
|
||||
# purpose: base class for PBot plugins
|
||||
|
||||
use warnings; use strict;
|
||||
|
||||
sub new {
|
||||
my ($proto, %conf) = @_;
|
||||
my $class = ref($proto) || $proto;
|
||||
my $self = bless {}, $class;
|
||||
|
||||
if (not exists $conf{pbot}) {
|
||||
my ($package, $filename, $line) = caller(0);
|
||||
my (undef, undef, undef, $subroutine) = caller(1);
|
||||
Carp::croak("Missing pbot reference to " . $class . ", created by $subroutine at $filename:$line");
|
||||
}
|
||||
|
||||
$self->{pbot} = $conf{pbot};
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($package, $filename, $line) = caller(0);
|
||||
my (undef, undef, undef, $subroutine) = caller(1);
|
||||
Carp::croak("Missing initialize subroutine in $subroutine at $filename:$line");
|
||||
}
|
||||
|
||||
sub unload {
|
||||
my ($package, $filename, $line) = caller(0);
|
||||
my (undef, undef, undef, $subroutine) = caller(1);
|
||||
Carp::croak("Missing unload subroutine in $subroutine at $filename:$line");
|
||||
}
|
||||
|
||||
1;
|
@ -8,10 +8,9 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Quotegrabs;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use HTML::Entities;
|
||||
@ -25,17 +24,8 @@ use PBot::Utils::ValidateString;
|
||||
|
||||
use POSIX qw(strftime);
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to Quotegrabs should be key/value pairs, not hash reference") if ref($_[1]) eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference in Quotegrabs");
|
||||
$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});
|
||||
|
@ -1,26 +1,14 @@
|
||||
|
||||
package Plugins::RelayUnreg;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.public', sub { $self->on_public(@_) });
|
||||
$self->{queue} = [];
|
||||
$self->{notified} = {};
|
||||
|
@ -3,34 +3,22 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::RemindMe;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use feature 'switch';
|
||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
use Carp ();
|
||||
use DBI;
|
||||
use Time::Duration qw/concise duration/;
|
||||
use Time::HiRes qw/gettimeofday/;
|
||||
use Getopt::Long qw(GetOptionsFromString);
|
||||
|
||||
Getopt::Long::Configure ("bundling");
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{commands}->register(sub { $self->remindme(@_) }, 'remindme', 0);
|
||||
$self->{filename} = $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/reminders.sqlite3';
|
||||
$self->{pbot}->{timer}->register(sub { $self->check_reminders(@_) }, 1, 'RemindMe');
|
||||
|
@ -3,6 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::RestrictedMod;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
# purpose: provides restricted moderation abilities to voiced users.
|
||||
# They are allowed to ban/mute/kick only users that are not admins,
|
||||
@ -10,25 +11,13 @@ package Plugins::RestrictedMod;
|
||||
# configurations where +v users are recognized as "semi-trusted" in
|
||||
# order to provide assistance in combating heavy spam and drone traffic.
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
use Carp ();
|
||||
|
||||
use Storable qw/dclone/;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{commands}->register(sub { $self->modcmd(@_) }, 'mod', 0);
|
||||
$self->{pbot}->{commands}->set_meta('mod', 'help', 'Provides restricted moderation abilities to voiced users. They can kick/ban/etc only users that are not admins, whitelisted, voiced or opped.');
|
||||
|
||||
|
@ -3,19 +3,17 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Spinach;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use warnings; use strict;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::RealBin/../..";
|
||||
|
||||
use feature 'switch';
|
||||
no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
use JSON;
|
||||
|
||||
use Lingua::EN::Fractions qw/fraction2words/;
|
||||
@ -38,18 +36,8 @@ use PBot::HashObject;
|
||||
use Plugins::Spinach::Stats;
|
||||
use Plugins::Spinach::Rank;
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{commands}->register(sub { $self->spinach_cmd(@_) }, 'spinach', 0);
|
||||
|
||||
$self->{pbot}->{timer}->register(sub { $self->spinach_timer }, 1, 'spinach timer');
|
||||
|
@ -3,6 +3,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::TypoSub;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
# purpose: Replaces "typos" with "corrections".
|
||||
#
|
||||
@ -16,23 +17,11 @@ package Plugins::TypoSub;
|
||||
# <alice> s/like/love/
|
||||
# <PBot> alice meant to say: i love candy
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.public', sub { $self->on_public(@_) });
|
||||
$self->{pbot}->{event_dispatcher}->register_handler('irc.caction', sub { $self->on_public(@_) });
|
||||
}
|
||||
|
@ -8,26 +8,14 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::UrlTitles;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
|
||||
$self->{pbot}->{registry}->add_default('text', 'general', 'show_url_titles', $conf{show_url_titles} // 1);
|
||||
$self->{pbot}->{registry}->add_default('array', 'general', 'show_url_titles_channels', $conf{show_url_titles_channels} // '.*');
|
||||
$self->{pbot}->{registry}->add_default('array', 'general', 'show_url_titles_ignore_channels', $conf{show_url_titles_ignore_channels} // 'none');
|
||||
|
@ -8,28 +8,18 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Weather;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
|
||||
use PBot::Utils::LWPUserAgentCached;
|
||||
use XML::LibXML;
|
||||
use Getopt::Long qw(GetOptionsFromString);
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
Getopt::Long::Configure("bundling");
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{commands}->register(sub { $self->weathercmd(@_) }, "weather", 0);
|
||||
}
|
||||
|
||||
@ -40,10 +30,7 @@ sub unload {
|
||||
|
||||
sub weathercmd {
|
||||
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
|
||||
my $usage = "Usage: weather [-u <user account>] [location]";
|
||||
Getopt::Long::Configure("bundling");
|
||||
|
||||
my $getopt_error;
|
||||
local $SIG{__WARN__} = sub {
|
||||
$getopt_error = shift;
|
||||
|
@ -8,10 +8,9 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
package Plugins::Wttr;
|
||||
use parent 'Plugins::Plugin';
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
||||
use warnings; use strict;
|
||||
use feature 'unicode_strings';
|
||||
use utf8;
|
||||
|
||||
@ -20,21 +19,12 @@ no if $] >= 5.018, warnings => "experimental::smartmatch";
|
||||
|
||||
use PBot::Utils::LWPUserAgentCached;
|
||||
use JSON;
|
||||
use Getopt::Long qw(GetOptionsFromString);
|
||||
use URI::Escape qw/uri_escape_utf8/;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
Carp::croak("Options to " . __FILE__ . " should be key/value pairs, not hash reference") if ref $_[1] eq 'HASH';
|
||||
my ($class, %conf) = @_;
|
||||
my $self = bless {}, $class;
|
||||
$self->initialize(%conf);
|
||||
return $self;
|
||||
}
|
||||
use Getopt::Long qw(GetOptionsFromString);
|
||||
Getopt::Long::Configure("bundling_override", "ignorecase_always");
|
||||
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot} = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||
$self->{pbot}->{commands}->register(sub { $self->wttrcmd(@_) }, "wttr", 0);
|
||||
}
|
||||
|
||||
@ -67,8 +57,6 @@ sub wttrcmd {
|
||||
);
|
||||
|
||||
my $usage = "Usage: wttr [-u <user account>] [location] [" . join(' ', map { "-$_" } @wttr_options) . "]";
|
||||
Getopt::Long::Configure("bundling_override", "ignorecase_always");
|
||||
|
||||
my $getopt_error;
|
||||
local $SIG{__WARN__} = sub {
|
||||
$getopt_error = shift;
|
||||
|
Loading…
Reference in New Issue
Block a user