3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-01-23 18:44:33 +01:00

ActionTrigger: silence undefined variable warnings

This commit is contained in:
Pragmatic Software 2019-12-14 09:54:38 -08:00
parent 0b6bd32961
commit 75b7d05a69

View File

@ -233,8 +233,8 @@ sub actiontrigger {
my $comma = ''; my $comma = '';
foreach my $trigger (@triggers) { foreach my $trigger (@triggers) {
$result .= "$comma$trigger->{trigger} -> $trigger->{action}"; $result .= "$comma$trigger->{trigger} -> $trigger->{action}";
$result .= " ($trigger->{level})" if $trigger->{level} != 0; $result .= " (level=$trigger->{level})" if $trigger->{level} != 0;
$result .= " [$trigger->{repeatdelay}]" if $trigger->{repeatdelay} != 0; $result .= " (repeatdelay=$trigger->{repeatdelay})" if $trigger->{repeatdelay} != 0;
$comma = ",\n"; $comma = ",\n";
} }
} }
@ -396,6 +396,8 @@ sub check_trigger {
foreach my $trigger (@triggers) { foreach my $trigger (@triggers) {
eval { eval {
$trigger->{lastused} = 0 if not defined $trigger->{lastused};
$trigger->{repeatdelay} = 0 if not defined $trigger->{repeatdelay};
if ($now - $trigger->{lastused} >= $trigger->{repeatdelay} and $text =~ m/$trigger->{trigger}/) { if ($now - $trigger->{lastused} >= $trigger->{repeatdelay} and $text =~ m/$trigger->{trigger}/) {
$trigger->{lastused} = $now; $trigger->{lastused} = $now;
my $data = { lastused => $now }; my $data = { lastused => $now };