3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 13:59:47 +01:00

Minor style clean-up

This commit is contained in:
Pragmatic Software 2020-01-19 20:00:01 -08:00
parent 349266b598
commit ed874c2dec
5 changed files with 13 additions and 22 deletions

View File

@ -38,8 +38,8 @@ sub initialize {
$self->{metadata} = PBot::HashObject->new(pbot => $self->{pbot}, name => 'Commands', filename => $conf{filename});
$self->load_metadata;
$self->register(sub { $self->set(@_); }, "cmdset", 90);
$self->register(sub { $self->unset(@_); }, "cmdunset", 90);
$self->register(sub { $self->set(@_) }, "cmdset", 90);
$self->register(sub { $self->unset(@_) }, "cmdunset", 90);
}
sub register {

View File

@ -20,7 +20,7 @@ use Time::HiRes qw(gettimeofday);
use Getopt::Long qw(GetOptionsFromString);
use POSIX qw(strftime);
use Storable;
use LWP::UserAgent ();
use LWP::UserAgent;
use JSON;
use PBot::Utils::SafeFilename;

View File

@ -211,12 +211,6 @@ sub is_present_similar {
$channel = lc $channel;
$nick = lc $nick;
=cut
use Devel::StackTrace;
my $trace = Devel::StackTrace->new(indent => 1, ignore_class => ['PBot::PBot', 'PBot::IRC']);
$self->{pbot}->{logger}->log("is_present_similar stacktrace: " . $trace->as_string() . "\n");
=cut
return 0 if not exists $self->{nicklist}->{$channel};
return $self->{nicklist}->{$channel}->{$nick}->{nick} if $self->is_present($channel, $nick);
return 0 if $nick =~ m/(?:^\$|\s)/; # not nick-like
@ -232,11 +226,6 @@ sub is_present_similar {
my $distance = fastdistance($nick, $person);
my $length = length $nick > length $person ? length $nick : length $person;
=cut
my $p = $length != 0 ? $distance / $length : 0;
$self->{pbot}->{logger}->log("[$percentage] $nick <-> $person: $p %\n");
=cut
if ($length != 0 && $distance / $length <= $percentage) {
return $self->{nicklist}->{$channel}->{$person}->{nick};
}

View File

@ -83,12 +83,6 @@ sub initialize {
# logger created first to allow other modules to log things
$self->{logger} = PBot::Logger->new(pbot => $self, filename => "$data_dir/log/log", %conf);
$self->{version} = PBot::VERSION->new(pbot => $self, %conf);
$self->{logger}->log($self->{version}->version . "\n");
$self->{logger}->log("Args: @ARGV\n") if @ARGV;
return if $conf{logger_only};
# make sure the environment is sane
if (not -d $data_dir) {
$self->{logger}->log("Data directory ($data_dir) does not exist; aborting...\n");
@ -105,12 +99,20 @@ sub initialize {
exit;
}
# then commands so the modules can register new commands
$self->{commands} = PBot::Commands->new(pbot => $self, filename => "$data_dir/commands", %conf);
# the version
$self->{version} = PBot::VERSION->new(pbot => $self, %conf);
$self->{logger}->log($self->{version}->version . "\n");
$self->{logger}->log("Args: @ARGV\n") if @ARGV;
# log the configured paths
$self->{logger}->log("data_dir: $data_dir\n");
$self->{logger}->log("module_dir: $module_dir\n");
$self->{logger}->log("plugin_dir: $plugin_dir\n");
$self->{timer} = PBot::Timer->new(timeout => 10, %conf);
$self->{commands} = PBot::Commands->new(pbot => $self, filename => "$data_dir/commands", %conf);
$self->{func_cmd} = PBot::FuncCommand->new(pbot => $self, %conf);
$self->{refresher} = PBot::Refresher->new(pbot => $self);

View File

@ -61,7 +61,7 @@ sub version_cmd {
return "/say " . $self->version . "; you have the latest version.";
}
} else {
my $nick = $self->{pbot}->{nicklist}->is_present_similar($arguments);
my $nick = $self->{pbot}->{nicklist}->is_present_similar($from, $arguments);
if ($nick) {
return "/say $nick: " . $self->version;
}