User:AnomieBOT/source/tasks/OnThisDayTagger.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: BAGBot, OnThisDayTagger, OrphanReferenceFixer, TaskRedirectChecker, TemplateSubster: * rvstartid changed to rvcontinue for continuation.
AnomieBOT (talk | contribs)
Updating published sources: OnThisDayTagger: * Converted the template to Scribunto, so no more need to count the available parameters. Yay!
Line 79:
my $screwup=' Errors? [[User:'.$api->user.'/shutoff/OnThisDayTagger]]';
 
$api->store->{'maxotd'}=1 unless exists($api->store->{'maxotd'});
$api->store->{'nextday'}=2640 unless exists($api->store->{'nextday'});
 
Line 191 ⟶ 190:
}
close X;
 
my $res=check_maxotd($api);
return $res if $res;
 
return undef;
Line 404 ⟶ 400:
$api->store->{"nextday"}=++$self->{'nextday'};
}
 
my $res=check_maxotd($api);
return $res if $res;
 
my $next=86400-($starttime%86400)-(time-$starttime);
Line 606 ⟶ 599:
$output.="<b><i>$buffer</i></b>" if($state eq 'both' && $buffer ne '');
return $output;
}
 
sub check_maxotd {
my $api=shift;
 
# Load template content
my $res=$api->rawpage('Template:On this day');
if($res->{'code'} eq 'shutoff'){
$api->warn("Task disabled: ".$res->{'content'}."\n");
return 300;
}
if($res->{'code'} ne 'success'){
$api->warn("Could not load Template:On this day: ".$res->{'error'}."\n");
return 60;
}
$res=$res->{'content'};
 
# Count date/oldid parameters available
my $i=1;
$i++ while(index($res, "{{{date$i|}}}")>0 && index($res, "{{{oldid$i|}}}")>0);
$i--;
 
# Check if it's enough
my $max=$api->store->{'maxotd'};
return 0 if $max<=$i;
 
# No, complain
$api->log("Whining about insufficient parameters in {{On this day}}");
my $summ="{{[[Template:On this day]]}} needs more parameters";
$res=$api->whine($summ, "It appears that {{tl|On this day}} only supports parameters up to <nowiki>{{{date$i}}} and {{{oldid$i}}}</nowiki>, and I have seen at least one page that needs $max. Please edit the template to include more calls to {{tl|On this day/link}}.", Summary => $summ, Pagename => $whine_to);
if($res->{'code'} eq 'shutoff'){
$api->warn("Task disabled: ".$res->{'content'}."\n");
return 300;
}
if($res->{'code'} ne 'success'){
$api->warn("Could not complain about {{On this day}}: ".$res->{'error'}."\n");
return 60;
}
return 0;
}
 
Line 703 ⟶ 657:
$i++;
}
$api->store->{'maxotd'}=$i-1 if $api->store->{'maxotd'}<$i-1;
$done=1;
return "{{$oname|".join('|', @$params)."}}";
Line 726 ⟶ 679:
$i++;
}
$api->store->{'maxotd'}=$i-1 if $api->store->{'maxotd'}<$i-1;
$templ.="}}";