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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: FlagIconRemover: * Consensus seems to exist for processing {{tl|Infobox dam}} as well. The discussion showed two opposes, one of which seemed to miss the point that the discussion was for {{tl|Infobox dam}} only and the ot
AnomieBOT (talk | contribs)
Updating published sources: SourceUploader: * Redirect source talk pages to the main talk page.
Line 327:
return $ret if $ret>60;
next if $ret>0;
$ret=redirect_talk($api, $src.$page);
return $ret if $ret;
delete($self->{'pages'}{$page});
}
Line 336 ⟶ 338:
return $ret if $ret>60;
next if $ret>0;
$ret=redirect_talk($api, 'User:'.$api->user."/$page");
return $ret if $ret;
delete($self->{'tasklists'}{$page});
}
Line 356 ⟶ 360:
}
}
my $tpageret=redirect_talk($api, $page);
return $tpage=~s/^User:/Userret talk:/if $ret;
my $txt=$tpage;
$txt=~s!^(User talk:[^/]+)/.*!$1!;
my $r={$api->resolve_redirects($txt)};
if(exists($r->{''})){
$api->warn("Error fetching redirects for $page: ".$r->{''}{'error'}."\n");
return 60;
}
$txt=$r->{$txt};
$txt="#REDIRECT [[$txt]]\n\nThis page is unwatched. Please direct comments to [[$txt]].";
$tok=$api->edittoken($tpage, EditRedir=>1, NoExclusion=>1);
if($tok->{'code'} eq 'shutoff'){
$api->warn("Task disabled: ".$tok->{'content'}."\n");
return 300;
}
return 60 if($tok->{'code'} ne 'success');
if(($tok->{'revisions'}[0]{'*'} // '') ne $txt){
my $r=$api->edit($tok, $txt, 'Redirect useless unwatched talk page to someplace useful.', 1, 1);
if($r->{'code'} ne 'success'){
$api->warn("Write error for $tpage: ".$r->{'error'}."\n");
return 60;
} else {
$api->log("Created $tpage");
}
}
$self->{'shutoff_pages'}=[@shutoff];
}
Line 417 ⟶ 397:
}
return 0;
}
 
sub redirect_talk {
my $api=shift;
my $page=shift;
 
my $tpage=$page;
$tpage=~s/^User:/User talk:/;
my $txt=$tpage;
$txt=~s!^(User talk:[^/]+)/.*!$1!;
my $r={$api->resolve_redirects($txt)};
if(exists($r->{''})){
$api->warn("Error fetching redirects for $page: ".$r->{''}{'error'}."\n");
return 60;
}
$txt=$r->{$txt};
$txt="#REDIRECT [[$txt]]\n\nThis page is unwatched. Please direct comments to [[$txt]].";
my $tok=$api->edittoken($tpage, EditRedir=>1, NoExclusion=>1);
if($tok->{'code'} eq 'shutoff'){
$api->warn("Task disabled: ".$tok->{'content'}."\n");
return 300;
}
return 60 if($tok->{'code'} ne 'success');
if(($tok->{'revisions'}[0]{'*'} // '') ne $txt){
my $r=$api->edit($tok, $txt, 'Redirect useless unwatched talk page to someplace useful.', 1, 1);
if($r->{'code'} ne 'success'){
$api->warn("Write error for $tpage: ".$r->{'error'}."\n");
return 60;
} else {
$api->log("Created $tpage");
}
}
return undef;
}