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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: AnomieBOT::API: * Add configuration variable (and accessor function) for the bot operator's username * Better logging when testing uploads All tasks: * Remove useless metadata field
AnomieBOT (talk | contribs)
Updating published sources: General: * Update for the addition of 'rvslots'. DatedCategoryDeleterTest: * Disable. It's clear that task won't be needed. BrokenRedirectDeleter: * Handle pages with newlines before the <code>#REDIRECT</code>.
 
(2 intermediate revisions by the same user not shown)
Line 1:
{{ombox|type=notice|text= Approved 2009-01-03<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 20]]}}
<sourcesyntaxhighlight lang="perl">
package tasks::AFDMergeFromCleaner;
 
Line 66:
 
# Get a list of templates redirecting to our targets
my %templates=$api->redirects_to_resolved(map "Template:$_", @templates);
foreach my $template if(@exists($templates{''})){
$api->warn("Failed to get redirects to target templates: ".$templates{''}{'error'}."\n");
$templates{"Template:$template"}=1;
$res=$api->query([],return 60;
list => 'backlinks',
bltitle => "Template:$template",
blfilterredir => 'redirects',
bllimit => 'max',
);
$templates{$_->{'title'}}=1 foreach (@{$res->{'query'}{'backlinks'}});
}
 
Line 149 ⟶ 143:
 
# Get page text
my $intxt=$tok->{'revisions'}[0]{'slots'}{'main'}{'*'};
 
# First, find the template and pull out the relevant parameter
Line 241 ⟶ 235:
last;
}
my $intxt=$tok->{'revisions'}[0]{'slots'}{'main'}{'*'} // '';
foreach my $s (split(/(?=(?:^|\n)==)/, $intxt)){
if($s=~/^\n?==\s*Redirected\s*==/){
Line 295 ⟶ 289:
1;
 
</syntaxhighlight>
</source>