Content deleted Content added
Updating published sources: General: * Fix newline handling in log messages. |
Updating published sources: WikiProjectTagger: * Adjustments to tag even if not assessing * Start run for WP Physics. AutoAssessor2: * Adjustments to tag even if not assessing * Adjust config for WP Physics run, and start running. AutoAssessor2, Wiki |
||
Line 26:
use strict;
use Data::Dumper;
use AnomieBOT::Task;
use vars qw/@ISA/;
Line 31 ⟶ 32:
# Request link, for edit summary.
my $req="[[User:AnomieBOT/req/WikiProject
# 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=
# If any of the 'verify' or 'params' functions need the page contents, set this
Line 55 ⟶ 56:
# results, the template name, and the existing template parameters. It
# should adjust the parameter array as necessary.
my %cfg_templates
%cfg_templates=(
ns => {
stub => [ 'stub', qr/\S.*/s, undef, undef ], redirect => [ 'redirect', qr/redirect|red|redir/i, 'NA', qr/na/i ],
disambig => [ 'disambig', qr/disambig|dab/i, 'NA', qr/na/i ],
stubauto => 'auto',▼
activepol => undef,
verify => undef,
params => sub {
my $api=shift;
my $page=shift;
my $talk=shift;
my $name=shift;
my $params=shift;
my @x=(@{$page->{'categories'} // []},@{$page->{'templates'} // []},@{$talk->{'categories'} // []},@{$talk->{'templates'} // []});
warn Dumper(\@x);
my $mark=0;
$mark|=1 if grep($_->{'title'} eq 'Template:WPBiography', @x);
$mark|=1 if grep($_->{'title'} eq 'Template:Blp', @x);
$mark|=8 if grep($_->{'title'} eq 'Template:WPBooks', @x);
$mark|=8 if grep($_->{'title'} eq 'Template:WikiProject Magazines', @x);
$mark|=8 if grep($_->{'title'} eq 'Template:WikiProject Academic Journals', @x);
$mark|=8 if grep($_->{'title'} eq 'Category:Journals', @x);
$mark|=8 if grep($_->{'title'} eq 'Category:Journal articles', @x);
$mark|=8 if grep($_->{'title'} eq 'Category:Scientific journals', @x);
$mark|=8 if grep($_->{'title'} eq 'Category:Scientific literature', @x);
$mark|=8 if grep($_->{'title'} eq 'Category:Academic publishing', @x);
$mark|=16 if grep($_->{'title'} eq 'Template:WikiProject History of Science', @x);
warn Dumper(\$mark);
if($mark&1){
push @$params, "bio=yes" unless(grep(s/^(\s*bio\s*=(?:\s*(?=\S))?).*?(\s*)$/${1}yes$2/s, @$params));
}
if($mark&2){
push @$params, "fluid-dynamics=yes" unless(grep(s/^(\s*fluid-dynamics\s*=(?:\s*(?=\S))?).*?(\s*)$/${1}yes$2/s, @$params));
}
if($mark&4){
push @$params, "relativity=yes" unless(grep(s/^(\s*relativity\s*=(?:\s*(?=\S))?).*?(\s*)$/${1}yes$2/s, @$params));
}
if($mark&8){
push @$params, "pub=yes" unless(grep(s/^(\s*pub\s*=(?:\s*(?=\S))?).*?(\s*)$/${1}yes$2/s, @$params));
}
if($mark&16){
push @$params, "hist=yes" unless(grep(s/^(\s*hist\s*=(?:\s*(?=\S))?).*?(\s*)$/${1}yes$2/s, @$params));
}
},▼
},
▲ stubauto => 'auto',
▲ canonicalize => 'Glass',
▲ verify => undef,
▲ params => undef,
▲ },
);
Line 94 ⟶ 135:
sub approved {
return
}
Line 101 ⟶ 142:
my $res;
$api->task('AutoAssessor2', 0, 10, qw/d::
# List of templates to assess in this task
Line 139 ⟶ 180:
my %q2=(
pageids => '',
prop => 'info|categories|templates',
cllimit => 'max',
tllimit => 'max',
);
if($need_page_contents){
Line 198 ⟶ 240:
# Ok, check the page
my $tok=$api->edittoken($talk, EditRedir => 1, 'categories'=>1, 'templates'=>1);
if($tok->{'code'} eq 'shutoff'){
$api->warn("Task disabled: ".$tok->{'content'}."\n");
Line 224 ⟶ 266:
return undef unless exists($templates{"Template:$name"});
my %cfg=%{$templates{"Template:$name"}};
return undef
my ($class,$classre,$imp,$impre)
($class,$classre,$imp,$impre)=@{$cfg{'ns'}{$ns}};
} else {
($class,$classre,$imp,$impre)=(undef,undef,undef,undef);
}
my $impname=exists($cfg{'importance'})?$cfg{'importance'}:'importance';
Line 248 ⟶ 294:
# Do extra parameters, if necessary
$cfg{'params'}($api,$page,$tok,$name,\@params) if defined($cfg{'params'});
my $new_param=join('|', @params);
Line 276 ⟶ 322:
# Need to edit?
if($outtxt ne $intxt && $any){
$outtxt=$api->WPBfixshell($outtxt);
$found[-1]='and '.$found[-1] if @found>1;
my $summary="Assessing ".join((@found>2)?', ':' ', @found)." per $req";
|