mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-23 04:19:27 +01:00
Factoids: properly set range for pick $variable modifier
This commit is contained in:
parent
b8ec975f67
commit
945b81f12d
@ -472,7 +472,7 @@ sub expand_factoid_vars {
|
|||||||
$action =~ s/(?<!\\)\$0/$root_keyword/g;
|
$action =~ s/(?<!\\)\$0/$root_keyword/g;
|
||||||
my $const_action = $action;
|
my $const_action = $action;
|
||||||
|
|
||||||
while ($const_action =~ /(\ba\s*|\ban\s*)?(?<!\\)\$(?:(\{[a-zA-Z0-9_#]+(?::[a-zA-Z0-9_(),.#:-]+)?\}|[a-zA-Z0-9_#]+(?::[a-zA-Z0-9_(),.#:-]+)?))/gi) {
|
while ($const_action =~ /(\ba\s*|\ban\s*)?(?<!\\)\$(?:(\{[a-zA-Z0-9_#]+(?::[a-zA-Z0-9_(),.#:+-]+)?\}|[a-zA-Z0-9_#]+(?::[a-zA-Z0-9_(),.#:+-]+)?))/gi) {
|
||||||
my ($indefinite_article, $v) = ($1, $2);
|
my ($indefinite_article, $v) = ($1, $2);
|
||||||
$indefinite_article = '' if not defined $indefinite_article;
|
$indefinite_article = '' if not defined $indefinite_article;
|
||||||
next if not defined $v;
|
next if not defined $v;
|
||||||
@ -594,7 +594,8 @@ sub expand_factoid_vars {
|
|||||||
} elsif ($settings{'pick'}) {
|
} elsif ($settings{'pick'}) {
|
||||||
my $min = $settings{'pick_min'};
|
my $min = $settings{'pick_min'};
|
||||||
my $max = $settings{'pick_max'};
|
my $max = $settings{'pick_max'};
|
||||||
$max = $#list if $max > $#list;
|
$max = @list if $max > @list;
|
||||||
|
$min = $max if $min > $max;
|
||||||
|
|
||||||
my $count = $max;
|
my $count = $max;
|
||||||
if ($settings{'random'}) {
|
if ($settings{'random'}) {
|
||||||
@ -604,7 +605,6 @@ sub expand_factoid_vars {
|
|||||||
my @choices;
|
my @choices;
|
||||||
while ($count-- > 0) {
|
while ($count-- > 0) {
|
||||||
my $index = int rand @list;
|
my $index = int rand @list;
|
||||||
|
|
||||||
my $choice = $list[$index];
|
my $choice = $list[$index];
|
||||||
|
|
||||||
if ($settings{'unique'}) {
|
if ($settings{'unique'}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user