From bede029261256d9525b7e32b4343900efa9af269 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 14 Feb 2011 07:25:15 +0000 Subject: [PATCH] factoids: probably adds/remove upper/lowercase keywords --- PBot/Factoids.pm | 12 +++--------- PBot/VERSION.pm | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index b5eb374e..ed798ccb 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -81,7 +81,6 @@ sub add_factoid { $type = lc $type; $channel = lc $channel; - $trigger = lc $trigger; $self->factoids->hash->{$channel}->{$trigger}->{enabled} = 1; $self->factoids->hash->{$channel}->{$trigger}->{type} = $type; @@ -100,7 +99,6 @@ sub remove_factoid { my ($channel, $trigger) = @_; $channel = lc $channel; - $trigger = lc $trigger; delete $self->factoids->hash->{$channel}->{$trigger}; $self->save_factoids; @@ -164,11 +162,7 @@ sub find_factoid { my @result = eval { foreach my $channel (sort keys %{ $self->factoids->hash }) { - if($exact_channel) { - next unless $from eq $channel; - } else { - next unless $from =~ m/^$channel$/i; - } + next unless lc $from eq lc $channel; foreach my $trigger (keys %{ $self->factoids->hash->{$channel} }) { if(not $exact_trigger and $self->factoids->hash->{$channel}->{$trigger}->{type} eq 'regex') { @@ -324,8 +318,6 @@ sub interpreter { $self->factoids->hash->{$channel}->{$keyword}->{last_referenced_on} = gettimeofday; $self->factoids->hash->{$channel}->{$keyword}->{last_referenced_in} = $from || "stdin"; - $self->{pbot}->logger->log("(" . (defined $from ? $from : "(undef)") . "): $nick!$user\@$host): $keyword: Displaying text \"" . $self->factoids->hash->{$channel}->{$keyword}->{action} . "\"\n"); - if(defined $tonick) { # !tell foo about bar $self->{pbot}->logger->log("($from): $nick!$user\@$host) sent to $tonick\n"); my $fromnick = $self->{pbot}->admins->loggedin($from, "$nick!$user\@$host") ? "" : "$nick wants you to know: "; @@ -369,6 +361,8 @@ sub interpreter { $result =~ s/\$args/$nick/gi; } + $self->{pbot}->logger->log("(" . (defined $from ? $from : "(undef)") . "): $nick!$user\@$host): $keyword: Displaying text \"" . $self->factoids->hash->{$channel}->{$keyword}->{action} . "\"\n"); + $result =~ s/\$nick/$nick/g; while ($result =~ /[^\\]\$([a-zA-Z0-9_\-]+)/g) { diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index e8d76054..37420eb0 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 318, + BUILD_REVISION => 319, BUILD_DATE => "2011-02-13", };