Content deleted Content added
Updating published sources: DatedCategoryCreater: * Approved! |
Updating published sources: DatedCategoryCreater: * Supplemental BRFA approved! The bot may now date categories in Category:Wikipedia categories sorted by month. |
||
Line 1:
{{ombox|type=notice|text= Approved 2012-05-30.<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 64]]}}
{{ombox|type=notice|text= Supplemental BRFA approved 2012-06-04.<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 65]]}}
<syntaxhighlight lang="perl">
package tasks::DatedCategoryCreator;
Line 11 ⟶ 12:
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 64
Status: Approved 2012-05-30
+BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 65
+Status: Approved 2012-06-04
Created: 2012-05-07
Create needed categories under [[:Category:Wikipedia maintenance categories sorted by month]] and [[:Category:Wikipedia categories sorted by month]].
=end metadata
Line 66 ⟶ 69:
=for info
Approved 2012-05-30.<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 64]]
=for info
Supplemental BRFA approved 2012-06-04.<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 65]]
=cut
Line 75 ⟶ 81:
sub run {
my ($self, $api)=@_;
my ($res, $iter);
$api->task('DatedCategoryCreator',0,0,qw/d::Talk d::Redirects d::Templates/);
Line 81 ⟶ 87:
my %did=();
my $curmonth=strftime('%B %Y', gmtime(time()+30*86400));
$yearre=join('|', 2004 .. ((gmtime(time()+86400))[5]+1900));
Line 87 ⟶ 93:
# Part 1: Create needed categories for the current month
for my $cat ('Wikipedia
$res=$api->query(▼
generator => 'categorymembers',
▲ gcmtitle => 'Category:Wikipedia maintenance categories sorted by month',
gcmlimit => 'max',
);▼
);
if($res->{'code'} ne 'success'){ $api->warn("Failed to get
return 60;▼
}▼
titles => bunchlist(500, map monthly_for_cat($_->{'title'}, $curmonth), values %{$res->{'query'}{'pages'}}),▼
while($_=$iter->next){▼
return 0 if $api->halting;▼
$api->warn("Failed to retrieve members in ".$iter->iterval.": ".$_->{'error'}."\n");▼
return 60;
}
▲ titles => bunchlist(500, map monthly_for_cat($_->{'title'}, $curmonth), values %{$res->{'query'}{'pages'}}),
▲ );
▲ while($_=$iter->next){
▲ return 0 if $api->halting;
▲ $api->warn("Failed to retrieve members in ".$iter->iterval.": ".$_->{'error'}."\n");
▲ return 60;
}
$res=$self->make_dated_cat($api, $_->{'title'}, 'current month');▼
▲ $res=$self->make_dated_cat($api, $_->{'title'}, 'current month');
return $res if $res;
▲ }
}
Line 175 ⟶ 183:
titles => "Category:$parent",
prop => 'categories',
clcategories => 'Category:Wikipedia maintenance categories sorted by month|Category:Wikipedia categories sorted by month',
);
if($res->{'code'} ne 'success'){
Line 186 ⟶ 194:
return 0;
}
my $type;
unless(grep $_->{'title'} eq 'Category:Wikipedia maintenance categories sorted by month', @{$res->{'categories'}}){▼
$type='maintenance category';
▲
$type='category';
} else {
$api->warn("Did not create category $title, because parent category $parent is not in Category:Wikipedia maintenance categories sorted by month or Category:Wikipedia categories sorted by month");
return 0;
}
Line 207 ⟶ 220:
return 0 unless exists($tok->{'missing'});
$api->log("Creating monthly dated
my $r=$api->edit($tok, $txt, "Creating monthly dated
if($r->{'code'} ne 'success'){
$api->warn("Write failed on $title: ".$r->{'error'}."\n");
|