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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: General: * Add lots of backslashes to regexes, because new Perl whines about unescaped left-braces.
AnomieBOT (talk | contribs)
Updating published sources: TalkTemplateMover: * Supplemental BRFA to handle additional templates (initially {{tl|interwiki copy}}) approved.
 
(3 intermediate revisions by the same user not shown)
Line 1:
{{ombox|type=notice|text= Approved 2009-07-09<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 31]]}}
{{ombox|type=notice|text= Supplemental BRFA approved 2024-02-04<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 82]]}}
<syntaxhighlight lang="perl">
package tasks::TalkTemplateMover;
Line 11 ⟶ 12:
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 31
Status: Approved 2009-07-09
+BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 82
+Status: Approved 2024-02-04
Created: 2009-06-18
 
Find transclusions of {{tl|translated page}} mistakenlyand placedother ontemplates articledocumented for talk pages
mistakenly placed on article pages, and move them to the corresponding talk page.
 
=end metadata
Line 32 ⟶ 35:
my %templates=(
'Template:Translated page' => 1,
'Template:Interwiki copy' => 1,
);
 
Line 51 ⟶ 55:
=for info
Approved 2009-07-09<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 31]]
 
=for info
Supplemental BRFA approved 2024-02-04<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 82]]
 
=cut
 
sub approved {
return 23;
}
 
Line 90 ⟶ 97:
prop => 'revisions',
rvprop => 'content',
rvslots => 'main',
);
while($_=$iter->next){
Line 100 ⟶ 108:
 
my $title=$_->{'title'};
my $intxt=$_->{'revisions'}[0]{'slots'}{'main'}{'*'};
my %tmpl=();
my @moved=();
Line 132 ⟶ 140:
$api->warn("Failed to get edit token for $title: ".$tok1->{'error'}."\n");
return 60;
} elsif($tok1->{'revisions'}[0]{'slots'}{'main'}{'*'} ne $intxt){
$api->log("Page changed while processing! Skip for now.");
next;
Line 151 ⟶ 159:
}
 
my $intalk=$tok2->{'revisions'}[0]{'slots'}{'main'}{'*'} // '';
my $outtalk=$api->process_templates($intalk, sub {
my $name=shift;
Line 165 ⟶ 173:
});
$outtalk=$self->tag($api, $outtalk, join("\n", values %tmpl)) if %tmpl;
my $summary="Moving $moved from [[:$title]] per that template's documentation";
if(!defined($tok1)){
$outtalk=~s/\s+$//;
Line 189 ⟶ 197:
}
if(defined($tok1)){
my $res=$api->edit($tok1, $outtxt, "Moving $moved to [[Talk:$title]] per that template's documentation. $screwup", 0, 1);
if($res->{'code'} ne 'success'){
$api->warn("Write failed on $title: $res->{error}\n");