mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-24 11:42:35 +01:00
Allow more sensible C Jeopardy filtering (do not treat underscores as word characters)
This commit is contained in:
parent
282d97936f
commit
b98b683cc2
@ -61,16 +61,16 @@ if (defined $ret) {
|
|||||||
$filter_text =~ s/,/, /g;
|
$filter_text =~ s/,/, /g;
|
||||||
$filter_text =~ s/, ([^,]+)$/ or $1/;
|
$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 @w = split /,/, $words;
|
||||||
my $sep = '';
|
my $sep = '';
|
||||||
$filter_regex .= '(?:';
|
$filter_regex .= '(?:';
|
||||||
foreach my $word (@w) {
|
foreach my $word (@w) {
|
||||||
$filter_regex .= $sep;
|
$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 .= quotemeta $word;
|
||||||
$filter_regex .= $word =~ m/\w$/ ? '\b' : '\B';
|
$filter_regex .= $word =~ m/[a-zA-Z0-9]$/ ? '\b' : '\B';
|
||||||
$sep = '|';
|
$sep = '|';
|
||||||
}
|
}
|
||||||
$filter_regex .= ')';
|
$filter_regex .= ')';
|
||||||
|
Loading…
Reference in New Issue
Block a user