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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: DeletionSortingCleaner: * Trial approved, 7 days
AnomieBOT (talk | contribs)
Updating published sources: d::Templates: * When getting the "sanitized" template name, strip bidi and whitespace as MediaWiki does. d::Talk: * Add to the standard note a note that if a reply is needed, go to the bot's talk page. DeletionSortingClean
Line 132:
my $name2=$1;
 
my return $cannoteditreason=undef;
REDO:
my $xfdtok=$api->edittoken($name);
Line 138 ⟶ 139:
$fail=300;
return undef;
goto REDO;}
if($xfdtok->{'code'} eq 'pageprotected'){
$cannoteditreason=$xfdtok->{'error'};
my $res=$api->query(
prop => 'revisions',
titles => $name,
rvprop => 'ids|timestamp|content|flags|user|size|comment',
);
$xfdtok=(values %{$res->{'query'}{'pages'}})[0];
$xfdtok->{'code'}=$res->{'code'};
$xfdtok->{'error'}=$res->{'error'};
}
if($xfdtok->{'code'} ne 'success'){
Line 147 ⟶ 159:
}
 
my %substlist=();
my $xfdintxt=$xfdtok->{'revisions'}[0]{'*'};
my $xfdouttxt=$api->process_templates($xfdintxt, sub {
Line 154 ⟶ 167:
 
return undef unless exists($xfdtemplates{"Template:$name"});
$substlist{$name}=1;
$wikitext=~s/^{{/{{subst:/; # }} }}
return $wikitext;
Line 160 ⟶ 174:
# We found templates to subst, so save the changed page and
# then reload it.
$api->logif(defined("Substing templates in $name"cannoteditreason));{
my $res= $api->editlog($xfdtok, $xfdouttxt, "[[Wikipedia:TemplateEditprotected substitution|substituting]]to closuresubst templates".$screwup, 1,in 1$name");
if( my $res->{'code'}talk=$name; ne$talk=~s/:/ 'success'){talk:/;
#my Don'@t=map worry about this error"{{[[Template:$_|$_]]}}", just assume thekeys discussion%substlist;
$t[$# is not closed t]='and retry'.$t[$#t] nextif time around.@t>1;
my $api->warnt=join("Save(@t>2)?', failed for $name':' ".$res->{'error'}."\n", @t);
my $brokens=(@t==1)?'':'s';
my $res=$api->whine("Editprotected request: please subst $t", "{{editprotected}} The template$s $t in [[$name|this page]] should be substed, but I cannot do so because \l$cannoteditreason. Please do so. Thanks.", Summary=>"[BOT] Editprotected request: please subst $t", Pagename=>$talk);
return undef;
if($res->{'code'} ne 'success'){
# Don't worry about this error, just assume the
# discussion is not closed and retry next time around.
$api->warn("Editprotected request failed for $name: ".$res->{'error'}."\n");
$broken=1;
return undef;
}
} else {
$api->log("Substing templates in $name");
my $res=$api->edit($xfdtok, $xfdouttxt, "[[Wikipedia:Template substitution|substituting]] closure templates".$screwup, 1, 1);
if($res->{'code'} ne 'success'){
# Don't worry about this error, just assume the
# discussion is not closed and retry next time around.
$api->warn("Save failed for $name: ".$res->{'error'}."\n");
$broken=1;
return undef;
}
goto REDO;
}
goto REDO;
}