Content deleted Content added
Updating published sources: TalkTemplateMover: * Trial complete, remove trial code. * Detect the case where the template to be moved is already on the target talk page but uses a different redirect or parameter spacing. |
Updating published sources: TalkTemplateMover: * Supplemental BRFA to handle additional templates (initially {{tl|interwiki copy}}) approved. |
||
(14 intermediate revisions by the same user not shown) | |||
Line 1:
{{ombox|type=notice|text=
{{ombox|type=notice|text= Supplemental BRFA approved 2024-02-04<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 82]]}}
<
package tasks::TalkTemplateMover;
Line 7 ⟶ 8:
=begin metadata
Bot: AnomieBOT
Task: TalkTemplateMover
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 31
Status:
+BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 82
+Status: Approved 2024-02-04
Created: 2009-06-18
Find transclusions of {{tl|translated page}}
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 50 ⟶ 54:
=for info
=for info
Supplemental BRFA approved 2024-02-04<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 82]]
=cut
sub approved {
return
}
Line 63 ⟶ 70:
$api->task('TalkTemplateMover', 0, 10, qw/d::Talk d::Templates d::Redirects d::Trial/);
my $screwup='
if(!$did_redir){
my %r=$api->
if(exists($r{''})){
$api->warn("Failed to get template redirects: ".$r{''}{'error'}."\n");
Line 73 ⟶ 80:
%templates=%r;
my %skip=$api->
if(exists($skip{''})){
$api->warn("Could not load list of redirects for skip templates: ".$skip{''}{'error'}."\n");
Line 90 ⟶ 97:
prop => 'revisions',
rvprop => 'content',
rvslots => 'main',
);
while(
return 0 if $api->halting;
Line 100 ⟶ 108:
my $title=$_->{'title'};
my $intxt=$_->{'revisions'}[0]{'slots'}{'main'}{'*'};
my %tmpl=();
my @moved=();
Line 119 ⟶ 127:
$moved[-1]='and '.$moved[-1] if @moved>1;
my $moved=join((@moved>2)?', ':' ', @moved);
my $tl_moved=$moved; $tl_moved=~s/\{\{/{{tl|/g;
$api->log("Moving $moved from $title to Talk:$title");
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
if(!defined($tok1)){
$outtalk=~s/\s+$//;
Line 189 ⟶ 197:
}
if(defined($tok1)){
my $res=$api->edit($tok1, $outtxt, "Moving $moved to
if($res->{'code'} ne 'success'){
$api->warn("Write failed on $title: $res->{error}\n");
Line 236 ⟶ 244:
$wikitext=_unstrip_templates($wikitext,$data);
my $
utf8::encode( $tmp ) if utf8::is_utf8( $tmp );
my $tag="\x02".sha256_base64($tmp)."\x03";
$tag=~tr!+/=!-_!d;
$data->{$tag}=$wikitext;
Line 246 ⟶ 256:
my $templ=shift;
$wikitext=~s!(\x02[a-zA-Z0-9_-]+\x03)!
return $wikitext;
}
Line 252 ⟶ 262:
1;
</syntaxhighlight>
|