mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-05 03:29:33 +01:00
Factoids: disregard error messages when not explicitly invoked
This commit is contained in:
parent
53e990bd32
commit
5ffde32d46
@ -95,6 +95,11 @@ sub interpreter($self, $context) {
|
|||||||
|
|
||||||
# if multiple channels have this keyword, then ask user to disambiguate
|
# if multiple channels have this keyword, then ask user to disambiguate
|
||||||
if (@chanlist> 1) {
|
if (@chanlist> 1) {
|
||||||
|
# but only if the bot is explicitly invoked
|
||||||
|
if (not $context->{addressed}) {
|
||||||
|
$self->{pbot}->{logger}->log("Factoid found in multiple channels; disregarding disambiguation because bot not explicitly invoked\n");
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return "Factoid `$original_keyword` exists in " . join(', ', @chanlist) . "; use `fact <channel> $original_keyword` to choose one.";
|
return "Factoid `$original_keyword` exists in " . join(', ', @chanlist) . "; use `fact <channel> $original_keyword` to choose one.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +112,12 @@ sub interpreter($self, $context) {
|
|||||||
return $self->interpreter($context);
|
return $self->interpreter($context);
|
||||||
}
|
}
|
||||||
|
|
||||||
# keyword still not found, try regex factoids
|
# keyword still not found, try regex factoids if the bot was explicitly invoked
|
||||||
|
if (not $context->{addressed}) {
|
||||||
|
$self->{pbot}->{logger}->log("No factoid found; disregarding error message because bot not explicitly invoked\n");
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
($channel, $keyword) =
|
($channel, $keyword) =
|
||||||
$self->{pbot}->{factoids}->{data}->find(
|
$self->{pbot}->{factoids}->{data}->find(
|
||||||
$context->{ref_from} ? $context->{ref_from} : $context->{from},
|
$context->{ref_from} ? $context->{ref_from} : $context->{from},
|
||||||
|
@ -121,15 +121,18 @@ sub process_line($self, $from, $nick, $user, $host, $text, $tags = '', $is_comma
|
|||||||
# but for now let's see how this goes and if people can figure it
|
# but for now let's see how this goes and if people can figure it
|
||||||
# out with minimal confusion.
|
# out with minimal confusion.
|
||||||
$command = $cmd_text if not length $command;
|
$command = $cmd_text if not length $command;
|
||||||
|
$context->{addressed} = 1;
|
||||||
goto CHECK_EMBEDDED_CMD;
|
goto CHECK_EMBEDDED_CMD;
|
||||||
}
|
}
|
||||||
|
|
||||||
# otherwise try to parse any potential commands
|
# otherwise try to parse any potential commands
|
||||||
if ($cmd_text =~ m/^\s*($nick_regex)[,:]?\s+$bot_trigger\{\s*(.+?)\s*\}\s*$/) {
|
if ($cmd_text =~ m/^\s*($nick_regex)[,:]?\s+$bot_trigger\{\s*(.+?)\s*\}\s*$/) {
|
||||||
# "somenick: !{command}"
|
# "somenick: !{command}"
|
||||||
|
$context->{addressed} = 1;
|
||||||
goto CHECK_EMBEDDED_CMD;
|
goto CHECK_EMBEDDED_CMD;
|
||||||
} elsif ($cmd_text =~ m/^\s*$bot_trigger\{\s*(.+?)\s*\}\s*$/) {
|
} elsif ($cmd_text =~ m/^\s*$bot_trigger\{\s*(.+?)\s*\}\s*$/) {
|
||||||
# "!{command}"
|
# "!{command}"
|
||||||
|
$context->{addressed} = 1;
|
||||||
goto CHECK_EMBEDDED_CMD;
|
goto CHECK_EMBEDDED_CMD;
|
||||||
} elsif ($cmd_text =~ m/^\s*($nick_regex)[,:]\s+$bot_trigger\s*(.+)$/) {
|
} elsif ($cmd_text =~ m/^\s*($nick_regex)[,:]\s+$bot_trigger\s*(.+)$/) {
|
||||||
# "somenick: !command"
|
# "somenick: !command"
|
||||||
@ -146,15 +149,27 @@ sub process_line($self, $from, $nick, $user, $host, $text, $tags = '', $is_comma
|
|||||||
$self->{pbot}->{logger}->log("No similar nick for $possible_nick_prefix; disregarding command.\n");
|
$self->{pbot}->{logger}->log("No similar nick for $possible_nick_prefix; disregarding command.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
$context->{addressed} = 1;
|
||||||
} elsif ($cmd_text =~ m/^$bot_trigger\s*(.+)$/) {
|
} elsif ($cmd_text =~ m/^$bot_trigger\s*(.+)$/) {
|
||||||
# "!command"
|
# "!command"
|
||||||
$command = $1;
|
$command = $1;
|
||||||
} elsif ($cmd_text =~ m/^.?\s*$botnick\s*[[:punct:]]?\s+(.+)$/i) {
|
$context->{addressed} = 1;
|
||||||
|
} elsif ($cmd_text =~ m/^.?\s*$botnick\s*[,:]\s+(.+)$/i) {
|
||||||
# "botnick: command"
|
# "botnick: command"
|
||||||
$command = $1;
|
$command = $1;
|
||||||
} elsif ($cmd_text =~ m/^(.+?),?\s+$botnick[?!.]*$/i) {
|
$context->{addressed} = 1;
|
||||||
|
} elsif ($cmd_text =~ m/^.?\s*$botnick\s+(.+)$/i) {
|
||||||
|
# "botnick command"
|
||||||
|
$command = $1;
|
||||||
|
$context->{addressed} = 0;
|
||||||
|
} elsif ($cmd_text =~ m/^(.+?),\s+$botnick[?!.]*$/i) {
|
||||||
# "command, botnick?"
|
# "command, botnick?"
|
||||||
$command = $1;
|
$command = $1;
|
||||||
|
$context->{addressed} = 1;
|
||||||
|
} elsif ($cmd_text =~ m/^(.+?)\s+$botnick[?!.]*$/i) {
|
||||||
|
# "command botnick?"
|
||||||
|
$command = $1;
|
||||||
|
$context->{addressed} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# check for embedded commands
|
# check for embedded commands
|
||||||
|
@ -25,8 +25,8 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4686,
|
BUILD_REVISION => 4687,
|
||||||
BUILD_DATE => "2023-09-21",
|
BUILD_DATE => "2023-09-23",
|
||||||
};
|
};
|
||||||
|
|
||||||
sub initialize {}
|
sub initialize {}
|
||||||
|
Loading…
Reference in New Issue
Block a user