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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: General: * Update for the addition of 'rvslots'. DatedCategoryDeleterTest: * Disable. It's clear that task won't be needed. BrokenRedirectDeleter: * Handle pages with newlines before the <code>#REDIRECT</code>.
AnomieBOT (talk | contribs)
Updating published sources: POTDPageCreator: * Adjust regex, people have started not leaving a newline.
 
(One intermediate revision by the same user not shown)
Line 70:
return $res if $res;
 
if ( $outtxt=~s!^\s*\Q{{POTD/$date/{{#invoke:random|number|\E(\d+)\Q}}|{{{1|{{{style|default}}}}}}}}\E\s*\n!{{POTD protected/$date/{{#invoke:random|number|$1}}|{{{1|{{{style|default}}}}}}}}\n! ) {
my $n = $1;
for ( my $i = 1; $i <= $n; $i++ ) {
Line 85:
}
 
push @edits, [ $page2, $tok2, $outtxt2, "Creating protected version of a [[WP:POTD]] template by substing from {{[[$srcpage2|POTD/$date/$i]]|row}}" ];
}
 
push @edits, [ $page, $tok, $outtxt, "Creating protected version of a [[WP:POTD]] template by adjusting [[$srcpage]]" ];
} elsif ( $outtxt=~s/^\s*\Q{{POTD {{{1|{{{style|default}}}}}}\E\s*\n/{{subst:POTD row\n/ ) {
push @edits, [ $page, $tok, $outtxt, "Creating protected version of a [[WP:POTD]] template by substing from {{[[$srcpage|POTD/$date]]|row}}" ];
} else {
$api->warn( "$srcpage doesn't begin with expected wikitext\n$outtxt" );
Line 98:
 
foreach my $edit (@edits) {
my ($page, $tok, $outtxt, $summary) = @$edit;
my $res = $api->edit($tok, $outtxt, 'Creating protected version of a [[WP:POTD]] template'$summary, 0, 1);
if($res->{'code'} ne 'success'){
$api->warn("Write for $page failed: " . $res->{'error'});