Content deleted Content added
Updating published sources: LanguageCategoryCreator: * New task! |
Updating published sources: LanguageCategoryCreator: * Approved! |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1:
{{ombox|type=notice|text=
<syntaxhighlight lang="perl">
package tasks::LanguageCategoryCreator;
Line 10:
Task: LanguageCategoryCreator
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 84
Status:
Created: 2025-04-10
Create needed categories
=end metadata
Line 29:
@ISA=qw/AnomieBOT::Task/;
my $screwup;
sub new {
Line 48 ⟶ 42:
=for info
=cut
sub approved {
return
}
Line 60 ⟶ 54:
$api->task('LanguageCategoryCreator',0,0,qw/d::Talk d::Redirects d::Templates/);
$screwup='Report errors at [[User:'.$api->user.'/shutoff/LanguageCategoryCreator]]';
my $cont = $self->{'dbcontinue'} // '';
Line 73 ⟶ 68:
$dbh->do( q{SET NAMES 'utf8'} );
# Load data from module
my $catsql = join( ' OR ', map { my $c = $_; $c =~ s/\\//g; $c =~ s/ /_/g; $c =~ s/\(\?<[nc]>\.\+\)/%/g; "cat_title LIKE " . $dbh->quote( $c ) } ( @textcats, @sourcecats ) );▼
my $res = $api->query(▼
text => '{{subst:#invoke:User:AnomieBOT/LanguageCategoryCreator|list_cat_likes}}',
);▼
$api->warn( "Failed to
return 60;▼
}▼
▲ my $catsql = join( ' OR ', map {
# Spend a max of 5 minutes on this task before restarting
Line 146 ⟶ 153:
my ($self,$api,$title)=@_;
#
my
$api->warn( "Failed to get category members for Category:$title: " . $res->{'error'} . "\n" );
return
}
$api->log( "Skipping Category:$title, has no members" );▼
if ( $title =~ /^$cat$/ ) {▼
▲ }
return 0;
}
#
action => 'parse',
title => '
text => "
▲ disablelimitreport => 1,
formatversion => 2,
);
Line 188 ⟶ 183:
my $txt = $res->{'parse'}{'text'};
▲ if ( $n ne '' ) {
▲ $api->log( "Sanity check failed for $title: For $n, $c !== $1\n" );
▲ }
▲ $res = $api->query(
▲ list => 'categorymembers',
▲ cmlimit => 1,
▲ formatversion => 2,
▲ );
▲ if ( $res->{'code'} ne 'success' ) {
▲ $api->warn( "Failed to get category members for $title: " . $res->{'error'} . "\n" );
▲ return 60;
▲ $api->log( "Skipping $title, has no members" );
return 0;
}
#
my $tok=$api->edittoken( "Category:$title", EditRedir => 1 );
if ( $tok->{'code'} eq 'shutoff' ) {
Line 255 ⟶ 209:
$api->log( "Creating language category in Category:$title" );
my $r = $api->edit( $tok, $
if ( $r->{'code'} ne 'success' ) {
$api->warn( "Write failed on Category:$title: " . $r->{'error'} . "\n" );
|