diff --git a/PBot/Commands.pm b/PBot/Commands.pm index 087c8f37..66429787 100644 --- a/PBot/Commands.pm +++ b/PBot/Commands.pm @@ -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 { diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 812c9b80..837f9dbb 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -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; diff --git a/PBot/NickList.pm b/PBot/NickList.pm index 920af598..b786f67f 100644 --- a/PBot/NickList.pm +++ b/PBot/NickList.pm @@ -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}; } diff --git a/PBot/PBot.pm b/PBot/PBot.pm index ef4b7a40..da58e6d6 100644 --- a/PBot/PBot.pm +++ b/PBot/PBot.pm @@ -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); diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 16577cef..66190dae 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -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; }