3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

Allow more sensible C Jeopardy filtering (do not treat underscores as word characters)

This commit is contained in:
Pragmatic Software 2017-02-20 18:08:38 -08:00
parent 282d97936f
commit b98b683cc2

View File

@ -61,16 +61,16 @@ if (defined $ret) {
$filter_text =~ s/,/, /g;
$filter_text =~ s/, ([^,]+)$/ or $1/;
print "[Filter active! Skipping questions containing $filter_text.]\n";
print "[Filter active! To view or change, use the `filter` command.]\n";
my @w = split /,/, $words;
my $sep = '';
$filter_regex .= '(?:';
foreach my $word (@w) {
$filter_regex .= $sep;
$filter_regex .= $word =~ m/^\w/ ? '\b' : '\B';
$filter_regex .= $word =~ m/^[a-zA-Z0-9]/ ? '\b' : '\B';
$filter_regex .= quotemeta $word;
$filter_regex .= $word =~ m/\w$/ ? '\b' : '\B';
$filter_regex .= $word =~ m/[a-zA-Z0-9]$/ ? '\b' : '\B';
$sep = '|';
}
$filter_regex .= ')';