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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: AccidentalLangLinkFixer: * Trial, 15 edits.
AnomieBOT (talk | contribs)
Updating published sources: CFDClerk: * Someone made a module to parse Wikipedia:Categories for discussion/Old unclosed discussions and produce Wikipedia:Categories for discussion/Awaiting closure, so stop editing the latter. AccidentalLangLinkFixer: * Fix category name in the task description.
 
(7 intermediate revisions by the same user not shown)
Line 1:
{{ombox|type=notice|text= InApproved trial (15 edits)2011-01-02.<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 43]]}}
<syntaxhighlight lang="perl">
package tasks::AccidentalLangLinkFixer;
Line 10:
Task: AccidentalLangLinkFixer
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 43
Status: InApproved trial2011-01-02
Created: 2010-09-11
 
Periodically checks pages in [[:Category:Pages automatically checked for
accidental languageincorrect links]] for categories and language links seemingly in
running text, and adds the necessary ":" to make them wikilinks instead.
 
Line 31:
@ISA=qw/AnomieBOT::Task/;
 
my @categories = (
my $category= 'Category:Pages automatically checked for accidental language links';,
'Category:Pages automatically checked for incorrect links',
);
my $frequency=600; # minutes
 
Line 46 ⟶ 49:
 
=for info
InApproved trial (15 edits)2011-01-02.<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 43]]
 
=cut
 
sub approved {
return 23;
}
 
Line 58 ⟶ 61:
my $res;
 
$api->task('AccidentalLangLinkFixer', 0, 10, qw/d::IWNS d::Nowiki d::Trial/);
 
$api->store->{'trial edit count'}=0 unless exists($api->store->{'trial edit count'});
return $api->trial_complete('AnomieBOT 43') if $api->store->{'trial edit count'}>=15;
 
my $help='User:'.$api->user.'/docs/AccidentalLangLinkFixer';
Line 76:
$self->{'iter'}=$api->iterator(
generator => 'categorymembers',
gcmtitle => $category[ @categories ],
gcmlimit => 500100,
prop => 'langlinks|categories',
lllimit => 'max',
Line 85:
}
while(my $pg=$self->{'iter'}->next){
my $category = $self->{'iter'}->iterval;
if(!$pg->{'_ok_'}){
$api->warn("Failed to retrieve page list for $category: ".$pg->{'error'}."\n");
Line 117 ⟶ 118:
 
# Fix any bad links
my $intxt=$tok->{'revisions'}[0]{'slots'}{'main'}{'*'};
my ($outtxt,$nowiki)=$api->strip_regex(qr/^(?:\s|<!--.*?-->|<\/?(?:noinclude|includeonly|onlyinclude)>)*\[\[\s*(?:$llre|$clre)\s*:[^]]*\]\](?:\s|<!--.*?-->|<\/?(?:noinclude|includeonly|onlyinclude)>)*$/m, $intxt);
($outtxt,$nowiki)=$api->strip_regex(qr/\[\[\s*(?:$clre)\s*:\s*(?:\|[^]]*)?\]\]/, $outtxt, $nowiki);
($outtxt,$nowiki)=$api->strip_nowiki($outtxt,$nowiki);
my @summary=();
Line 133 ⟶ 135:
next;
}
return $api->trial_complete('AnomieBOT 43') if ++$api->store->{'trial edit count'}>=15;
} else {
$api->log("Updating saved category and language links for $page");