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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectWorker: * WikiProject NATO run seems to be complete AnomieBOT::API * Slightly better error handling when MediaWiki:Missing-article occurs when etching tokens.
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectWorker: * Start run for WikiProject California d::WikiProjectTagging: * WPBmin/WPBmax fix for comments in the value.
Line 33:
 
### Request link, for edit summary.
my $req="[[User:AnomieBOT/req/WikiProject NATOCalifornia 1|request]]";
 
### Increment this number every time a new run is started, so we don't have to
### mess around with deleting previous runs' database entries.
my $seq=34;
 
### How to find the pages?
Line 44:
list => 'categorymembers',
cmtitle => [
'Category:NATOUnassessed California articles',
'Category:Military facilities of NATO',
'Category:NATO installations by country',
'Category:NATO installations in Belgium',
'Category:NATO installations in Canada',
'Category:NATO installations in Germany',
'Category:NATO installations in Italy',
'Category:NATO installations in Turkey',
'Category:Enlargement of NATO',
'Category:NATO Secretaries General',
'Category:Military operations involving NATO',
'Category:NATO-led peacekeeping in the former Yugoslavia',
'Category:NATO operations in Afghanistan',
'Category:NATO military exercises',
'Category:Military units and formations of NATO',
'Category:NATO Standardisation Agreements',
'Category:NATO agencies',
'Category:NATO reporting names',
'Category:Military ranks of NATO',
'Category:NATO Supreme Allied Commanders',
'Category:NATO summits',
'Category:United States ambassadors to NATO',
],
cmnamespace => '0|1',
Line 78 ⟶ 57:
$t="Talk:$t" if $_[0]->{'ns'} == 0;
return $t;
}
 
### How to copy other projects' assessments
sub copy_class {
my ($api, $intxt) = @_;
my ($class) = $api->WPBmax($intxt);
return $class;
}
 
sub copy_importance {
return '';
}
 
# Banner configurations.
my %banner_cfgs=(
'WikiProject NATOCalifornia' => {
meta => 0,
stubauto => 'auto',
canonicalize => 'WikiProject NATOCalifornia',
},
);
Line 105 ⟶ 95:
 
sub approved {
return -1;
}
 
Line 179 ⟶ 169:
my @params=();
 
my $assess = undef;;
my ($class) = copy_class($api->WPBmax(, $intxt);
if(ref($class) neeq 'FA' && $class ne 'GAHASH'){
$api->warn("Processing $class)title =failed: ".$apiclass->WPBmin($intxt{'error'}."\n");
next;
}
if($class neeq 'FA' && $class ne 'GA'){
$assess=$api->WPBassess($title);
if(ref($assess) eq 'HASH'){
Line 198 ⟶ 189:
} else {
push @params, "class=$class";
my $imp = copy_importance($api, $intxt);
if(ref($imp) eq 'HASH'){
$api->warn("Processing $title failed: ".$imp->{'error'}."\n");
next;
}
push @params, "importance=$imp" if $imp eq '';
}
 
$outtxt=$api->WPBadd($outtxt, $assess, sub {
return $_[4]shift; # banner
}, 'WikiProject NATO', @params) shift; # name
my $oname=shift;
my $params=shift;
shift; # wikitext
my $new=shift;
return undef if $new;
 
foreach my $p (@params){
next unless $p=~/^(.+?)=(.*)$/;
my ($k,$v)=($1,$2);
unless(grep(/^\s*\Q$k\E\s*=\s*\S/, @$params)){
push @$params, "$k=$v" unless(grep(s/^(\s*\Q$k\E\s*=)(\s*)$/$1$v$2/s, @$params));
}
}
 
return "{{$oname}}" unless @$params;
return "{{$oname|".join("|", @$params)."}}";
}, 'WikiProject California', @params);
if(ref($outtxt) eq 'HASH'){
$api->warn("Processing $title failed: ".$outtxt->{'error'}."\n");
Line 219 ⟶ 233:
 
my $cat=$iter->iterval;
my $summary="Assessing for WikiProject NATO based on membership in [[$cat]]California per $req $errto";
$api->warn("$summary in $title\n");
my $r=$api->edit($tok, $outtxt, $summary, 1, 1);