diff --git a/PBot/FactoidCommands.pm b/PBot/FactoidCommands.pm index 660c65af..d454f216 100644 --- a/PBot/FactoidCommands.pm +++ b/PBot/FactoidCommands.pm @@ -49,16 +49,18 @@ sub initialize { $pbot->commands->register(sub { return $self->factalias(@_) }, "factalias", 0); $pbot->commands->register(sub { return $self->call_factoid(@_) }, "fact", 0); - $pbot->commands->register(sub { return $self->list(@_) }, "list", 0); - $pbot->commands->register(sub { return $self->add_regex(@_) }, "regex", 0); - $pbot->commands->register(sub { return $self->histogram(@_) }, "histogram", 0); - $pbot->commands->register(sub { return $self->top20(@_) }, "top20", 0); - $pbot->commands->register(sub { return $self->count(@_) }, "count", 0); - $pbot->commands->register(sub { return $self->find(@_) }, "find", 0); - $pbot->commands->register(sub { return $self->load_module(@_) }, "load", 50); - $pbot->commands->register(sub { return $self->unload_module(@_) }, "unload", 50); - $pbot->commands->register(sub { return $self->enable_command(@_) }, "enable", 10); - $pbot->commands->register(sub { return $self->disable_command(@_) }, "disable", 10); + # the following commands have not yet been updated to use the new factoid structure + # DO NOT USE!! Factoid corruption may occur. + $pbot->commands->register(sub { return $self->list(@_) }, "list", 999); + $pbot->commands->register(sub { return $self->add_regex(@_) }, "regex", 999); + $pbot->commands->register(sub { return $self->histogram(@_) }, "histogram", 999); + $pbot->commands->register(sub { return $self->top20(@_) }, "top20", 999); + $pbot->commands->register(sub { return $self->count(@_) }, "count", 999); + $pbot->commands->register(sub { return $self->find(@_) }, "find", 999); + $pbot->commands->register(sub { return $self->load_module(@_) }, "load", 999); + $pbot->commands->register(sub { return $self->unload_module(@_) }, "unload", 999); + $pbot->commands->register(sub { return $self->enable_command(@_) }, "enable", 999); + $pbot->commands->register(sub { return $self->disable_command(@_) }, "disable", 999); } sub call_factoid { @@ -267,7 +269,7 @@ sub factadd { return "/msg $nick Usage: factadd is "; } - my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($from_chan, $keyword, undef, 1); + my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($from_chan, $keyword, undef, 1, 1); if(defined $trigger) { $self->{pbot}->logger->log("$nick!$user\@$host attempt to overwrite $keyword\n"); @@ -292,7 +294,7 @@ sub factrem { return "/msg $nick Usage: factrem "; } - my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($from_chan, $from_trigger, undef, 1); + my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($from_chan, $from_trigger, undef, 1, 1); if(not defined $trigger) { return "/msg $nick $from_trigger not found in channel $from_chan."; @@ -351,7 +353,7 @@ sub factshow { return "Usage: factshow "; } - my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($chan, $trig); + my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($chan, $trig, undef, 0, 1); if(not defined $trigger) { return "/msg $nick '$trig' not found in channel '$chan'"; @@ -375,7 +377,7 @@ sub factinfo { return "Usage: factinfo "; } - my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($chan, $trig); + my ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($chan, $trig, undef, 0, 1); if(not defined $trigger) { return "'$trig' not found in channel '$chan'"; @@ -592,7 +594,7 @@ sub factchange { return "Usage: factchange s///"; } - ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($channel, $keyword); + ($channel, $trigger) = $self->{pbot}->factoids->find_factoid($channel, $keyword, undef, 0, 1); if(not defined $trigger) { return "/msg $nick $keyword not found in channel $from."; diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 1629389f..28a872e8 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -154,7 +154,7 @@ sub export_factoids { } sub find_factoid { - my ($self, $from, $keyword, $arguments, $exact_channel) = @_; + my ($self, $from, $keyword, $arguments, $exact_channel, $exact_trigger) = @_; $from = '.*' if not defined $from; @@ -168,7 +168,7 @@ sub find_factoid { next unless $from =~ m/$channel/i; } foreach my $trigger (keys %{ $self->factoids->hash->{$channel} }) { - if($self->factoids->hash->{$channel}->{$trigger}->{type} eq 'regex') { + if(not $exact_trigger and $self->factoids->hash->{$channel}->{$trigger}->{type} eq 'regex') { if($string =~ m/$trigger/i) { return ($channel, $trigger); } @@ -229,7 +229,7 @@ sub interpreter { } if(exists $self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on}) { - if(gettimeofday - $self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on} <= $self->factoids->hash->{$channel}->{$keyword}->{rate_limit}) { + if(gettimeofday - $self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on} < $self->factoids->hash->{$channel}->{$keyword}->{rate_limit}) { return "/msg $nick '$keyword' is rate-limited; try again in " . ($self->factoids->hash->{$channel}->{$keyword}->{rate_limit} - int(gettimeofday - $self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on})) . " seconds."; } } @@ -306,7 +306,7 @@ sub interpreter { $result =~ s/\$nick/$nick/g; while ($result =~ /[^\\]\$([a-zA-Z0-9_\-\.]+)/g) { - my ($var_chan, $var) = $self->find_factoid($from, $1); + my ($var_chan, $var) = $self->find_factoid($from, $1, undef, 0, 1); if(defined $var && $self->factoids->hash->{$var_chan}->{$var}->{type} eq 'text') { my $change = $self->factoids->hash->{$var_chan}->{$var}->{action}; @@ -340,7 +340,7 @@ sub interpreter { my $string = "$keyword" . (defined $arguments ? " $arguments" : ""); if($string =~ m/$keyword/i) { $self->{pbot}->logger->log("[$string] matches [$keyword] - calling [" . $self->factoids->hash->{$channel}->{$keyword}->{action} . "$']\n"); - my $cmd = "${ $self->factoids }{$keyword}{regex}$'"; + my $cmd = $self->factoids->hash->{$channel}->{$keyword}->{action} . $'; my ($a, $b, $c, $d, $e, $f, $g, $h, $i, $before, $after) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $`, $'); $cmd =~ s/\$1/$a/g; $cmd =~ s/\$2/$b/g; diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 9b9c9db0..e48e81d4 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,8 +13,8 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 203, - BUILD_DATE => "2010-06-22", + BUILD_REVISION => 204, + BUILD_DATE => "2010-06-26", }; 1;