Content deleted Content added
Updating published sources: WikiProjectWorker: * Don't choke when trying to assess talk pages for nonexistant subpages, just don't assess them. |
Updating published sources: WikiProjectWorker: * Done with WikiProject Japan tagging. * Start WPVG task force merging. Someone stole most of it, though :( conf.sample.ini: * Add a note about SQLite's coarse locking, which can be worked around with a |
||
Line 32:
@ISA=qw/AnomieBOT::Task/;
### Request link, for edit summary.
my $req="[[User:AnomieBOT/req/
### 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=
### How to find the pages?
my
my @iterators=(
{
list => 'embeddedin',
eititle => [ map "Template:$_",
eilimit => 'max',
},
);
### Filter function: manipulate the found data as necessary, returning the talk
### page to tag (or undef to skip).
sub filter {
return $_[0]->{'title'};
Line 57:
# Banner configurations.
my %banner_cfgs=(
'WikiProject
meta => 0,
stubauto => undef,
canonicalize => 'WikiProject
},
);
Line 101:
}
if(($api->store->{'configured'} // 0) < $seq){
### Initialize configuration here
$api->store->{'conflicting assessments'}='';▼
#$api->store->{'
}
### Update log page
#if($api->store->{'conflicting assessments'} ne '' || $api->store->{'NA assessments'} ne ''){
# my $tok=$api->edittoken('Wikipedia:WikiProject Japan/Assessment/Tag cleanup');
# if($tok->{'code'} ne 'success'){
# $api->warn("Cannot update log: ".$tok->{'error'}."\n");
# return 60;
# }
# my $txt=$tok->{'revisions'}[0]{'*'};
# my $a=$api->store->{'conflicting assessments'};
# my $b=$api->store->{'NA assessments'};
# unless($txt=~s/(<!-- Insert conflicting assessments above here -->)/$a$1/ &&
# $txt=~s/(<!-- Insert NA assessments above here -->)/$b$1/){
# $api->warn("Log is missing conflicting assessments marker");
# $api->whine("[[Wikipedia:WikiProject Japan/Assessment/Tag cleanup]] is broken", "Help! [[Wikipedia:WikiProject Japan/Assessment/Tag cleanup]] is missing the comments that tell me where to insert new log entries. I can't do anything to that page until someone fixes it.");
# return 60;
# }
# $api->warn("Updating log\n");
# my $r=$api->edit($tok, $txt, "Bot updating log", 0, 0);
# if($r->{'code'} ne 'success'){
# $api->warn("Write failed on log: ".$r->{'error'}."\n");
# return 60;
# }
# $api->store->{'conflicting assessments'}='';
# $api->store->{'NA assessments'}='';
#}
# Preload cache
$api->redirects_to(map "Template:$_",
# Spend a max of 5 minutes on this task before restarting
Line 183 ⟶ 184:
# Is there a WikiProject Japan template already on the page?
my $
# First, remove the to-be-removed templates and calculate task
Line 191 ⟶ 192:
my $imp=undef;
my %tf=();
(undef,$outtxt)=$api->WPBcheck($outtxt, sub {
my $banner=shift;
my $oname=shift;
my @params=@{shift()};
▲ $tf{'myth'}=1 if $banner eq 'Jmyth';
foreach (@params) {
if(/^\s*class\s*=\s*(\S.*?)\s*$/s){
Line 211 ⟶ 210:
$fail=1 if(defined($imp) && lc($imp) ne lc($1));
$imp=$1;
}▼
my $x=lc($1);▼
}
}
return
}, keys
▲ }, @templates);
if(ref($outtxt) eq 'HASH'){
$api->warn("Processing $title failed: ".$outtxt->{'error'}."\n");
Line 241 ⟶ 221:
}
# Second, add (or replace) {{WikiProject
my @tf=map "$_=yes", keys %tf;
my @assess=();
if($fail){
#$api->store->{'conflicting assessments'}.="* [[:$title]]\n";
} else {
push @assess, "class=$class" if defined($class);
push @assess, "importance=$imp" if defined($imp);
#$api->store->{'NA assessments'}.="* [[:$title]]\n" if ($class // '') eq 'na';
}
my $assess=undef;
Line 272 ⟶ 253:
my $new=shift;
return undef if $new;
$params = [ grep $_!~/^\s*tf[23]?\s*=/, @$params ];▼
foreach my $tf (keys %tf) {
Line 281 ⟶ 260:
if(@assess){
if(defined($class)){
▲ push @$params, "class=$class"
▲ }
}
if(defined($imp)){
push @$params, "importance=$imp" unless(grep(s/^(\s*importance\s*=)(\s*)$/$1$imp$2/s, @$params));
}
}
Line 290 ⟶ 273:
return "{{$oname}}" unless @$params;
return "{{$oname|".join("|", @$params)."}}";
}, 'WikiProject
if(ref($outtxt) eq 'HASH'){
$api->warn("Processing $title failed: ".$outtxt->{'error'}."\n");
Line 306 ⟶ 289:
}
my
$found[-1]='and '.$found[-1] if @found>1;
my $summary="Replacing ".join((@found>2)?', ':' ', @found)." with {{WikiProject Video games|".join('|', values %found)."}} per $req $errto";
$api->warn("$summary in $title\n");
my $r=$api->edit($tok, $outtxt, $summary, 1, 1);
|