mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +01:00
Factoids: improve nested selectors
This commit is contained in:
parent
b0789099df
commit
5676d6f13b
@ -535,8 +535,9 @@ sub make_list {
|
||||
my ($self, $context, $extracted, $settings, %opts) = @_;
|
||||
|
||||
if ($extracted =~ /(.*?)(?<!\\)%\s*\(.*\)/) {
|
||||
$opts{nested} = 1;
|
||||
$opts{nested}++;
|
||||
$extracted = $self->expand_factoid_selectors($context, $extracted, %opts);
|
||||
$opts{nested}--;
|
||||
}
|
||||
|
||||
my @list;
|
||||
@ -544,9 +545,7 @@ sub make_list {
|
||||
$item =~ s/^\s+|\s+$//g;
|
||||
$item =~ s/\\\|/|/g;
|
||||
|
||||
my @items = $self->expand_factoid_vars($context, $item, %opts);
|
||||
|
||||
foreach $item (@items) {
|
||||
if ($settings->{'uc'}) { $item = uc $item; }
|
||||
|
||||
if ($settings->{'lc'}) { $item = lc $item; }
|
||||
@ -559,9 +558,8 @@ sub make_list {
|
||||
}
|
||||
|
||||
if ($settings->{'json'}) { $item = $self->escape_json($item); }
|
||||
}
|
||||
|
||||
push @list, @items;
|
||||
push @list, $item;
|
||||
}
|
||||
|
||||
if ($settings->{'unique'}) {
|
||||
@ -584,21 +582,9 @@ sub make_list {
|
||||
sub select_item {
|
||||
my ($self, $context, $extracted, $modifier, %opts) = @_;
|
||||
|
||||
my %default_opts = (
|
||||
nested => 0,
|
||||
);
|
||||
|
||||
%opts = (%default_opts, %opts);
|
||||
|
||||
my %settings = $self->parse_expansion_modifiers($modifier);
|
||||
|
||||
if ($opts{nested}) {
|
||||
my $list = $self->make_list($context, $extracted, \%settings, %opts);
|
||||
@$list = map { $_ .= $$modifier } @$list;
|
||||
$$modifier = '';
|
||||
return join ('|', @$list);
|
||||
}
|
||||
|
||||
my $item;
|
||||
|
||||
if (exists $settings{'index'}) {
|
||||
|
Loading…
Reference in New Issue
Block a user