3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-03 01:48:38 +02:00

factoids: probably adds/remove upper/lowercase keywords

This commit is contained in:
Pragmatic Software 2011-02-14 07:25:15 +00:00
parent 438b62552f
commit bede029261
2 changed files with 4 additions and 10 deletions

View File

@ -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) {

View File

@ -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",
};