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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: AccidentalLangLinkFixer, AltLinkTemplateSubster, ShowByDateSubster, TalkTemplateMover: * Move to runner 3. CFDClerk, DatedCategoryCreator, PeerReviewArchiver, POTDPageCreator: * Move to runner 2.
AnomieBOT (talk | contribs)
Updating published sources: POTDPageCreator: * Remove {{tag|noinclude|o}} bits when copying the unprotected version.
Line 51:
my ($self, $api)=@_;
 
$api->task('POTDPageCreator', 0, 10, qw(d::Talk d::Nowiki d::Trial));
 
my $trial = $api->check_trial( 1486560586, 'AnomieBOT 77' );
Line 102:
return 60;
}
 
my $txtintxt = $res->{'query'}{'pages'}[0]{'revisions'}[0]{'content'} // '';
unless ( $txt=~s/^\s*\Q{{POTD {{{1|{{{style|default}}}}}}\E\s*\n/{{subst:POTD row\n/ ) {
# Act like preloading does
$api->warn( "$srcpage doesn't begin with \"{{POTD {{{1|{{{style|default}}}}}}\"!\n$txt" );
my ($outtxt,$nowiki) = $api->strip_nowiki($intxt);
$outtxt = join( '', $outtxt=~m!<onlyinclude>(.*?)</onlyinclude>!sg ) if $outtxt=~m!<onlyinclude>.*?</onlyinclude>!s;
$outtxt =~ s!<noinclude>.*?</noinclude>!!sg;
$outtxt =~ s!</?includeonly>!!g;
$outtxt =~ s!<(?:includeonly|noinclude)\s*/>!!g;
$outtxt = $api->replace_nowiki($outtxt, $nowiki);
 
unless ( $txtouttxt=~s/^\s*\Q{{POTD {{{1|{{{style|default}}}}}}\E\s*\n/{{subst:POTD row\n/ ) {
$api->warn( "$srcpage doesn't begin with \"{{POTD {{{1|{{{style|default}}}}}}\"!\n$txtouttxt" );
$api->whine( "[[$srcpage]] has unexpected content", "While attempting to create [[$page]], I found that [[$srcpage]] does not begin with <code><nowiki>{{POTD {{{1|{{{style|default}}}}}}</nowiki></code>. Please fix it, or create [[$page]] manually.", Pagename => $talk );
return 60;
}
 
$res = $api->edit($tok, $txtouttxt, 'Creating protected version of a [[WP:POTD]] template', 0, 1);
if($res->{'code'} ne 'success'){
$api->warn("Write for $page failed: " . $res->{'error'});