Content deleted Content added
Updating published sources: General: * Function to transparently handle continuations in an API query. * Fix bot.pl to correctly check the ChangeLog mtime. WatchlistUpdater: * Change around to handle arbitrary API queries, with filtering. SourceUploa |
Updating published sources: General: * fullquery: If multiple continues are returned, process them in parallel. WatchlistUpdater: * More changing around, to allow output other than a table. * Improve error handling. |
||
Line 46:
match => {},
summary => 'Automatically updating list of uw-* templates',
botflag => 1,
outprefix => sub { "{| class=\"wikitable\"\n" },
} else {▼
}▼
} else {▼
substr($talk, index($talk, ':'), 0)=' talk';▼
return "|-\n|[[$main]]||[[$talk]]\n",
},
outerror => sub { "|-\n|colspan=\"2\"|".$_[1]."\n" },
outsuffix => sub { "|}" }
},
{
Line 64 ⟶ 82:
match => {},
summary => 'Automatically updating userspace index',
botflag => 1,
outprefix => sub { "{| class=\"wikitable\"\n" },
outformat => sub {
my ($main, $talk);
if($_[1]{'ns'}==14 || $_[1]{'ns'}==6){
$main=':'.$_[1]{'title'};
} else {
$main=$_[1]{'title'};
}
if($_[1]{'ns'}==0){
$talk="Talk:".$_[1]{'title'};
} else {
$talk=$_[1]{'title'};
substr($talk, index($talk, ':'), 0)=' talk';
}
return "|-\n|[[$main]]||[[$talk]]\n",
},
outerror => sub { "|-\n|colspan=\"2\"|".$_[1]."\n" },
outsuffix => sub { "|}" }
}
);
Line 137 ⟶ 173:
if($tok->{'code'} ne 'success'){
$self->warn("Failed to retrieve edit token for $page: ".$tok->{'error'});
}
if(exists($tok->{'missing'})){
$self->warn("Page $page does not exist");
$data->{'lastrun'}=time();
next;
}
Line 153 ⟶ 190:
if($res->{'code'} ne 'success'){
$self->warn("Failed to retrieve data for $page: ".$res->{'error'});
}
%cont=();
Line 174 ⟶ 211:
next if ($_->{'ns'}&1)==1;
next unless _match($data->{'match'}, $_);
▲ if($_->{'ns'}==14 || $_->{'ns'}==6){
▲ $main=':'.$_->{'title'};
▲ } else {
▲ $main=$_->{'title'};
▲ }
▲ if($_->{'ns'}==0){
▲ $talk="Talk:".$_->{'title'};
▲ } else {
▲ $talk=$_->{'title'};
▲ substr($talk, index($talk, ':'), 0)=' talk';
▲ }
▲ $out{$_->{'title'}}=[$main,$talk];
last if ++$rows>$data->{'maxrows'};
}
} while($rows<=$data->{'maxrows'} && values(%cont));
my $
map { $table.=$data->{'outformat'}($x,$out{$_}); } sort keys %out;
$table.=
▲ $table.="|}";
$table.=$data->{'outsuffix'}($x);
# Perform edit, if needed
Line 222 ⟶ 248:
next;
}
$self->warn("Updated $page\n");
}
}
Line 233 ⟶ 260:
my $t=864000; # arbitrary initial/max value
foreach (@{$self->{'pages'}}){
next if $_->{'lastrun'}==0;
my $tt=$_->{'lastrun'}+$_->{'frequency'}-time();
$t=$tt if $tt<$t;
Line 242 ⟶ 270:
my $match = shift;
my $value = shift;
return $match->($value) if(ref($match) eq 'CODE');
if(ref($match) eq 'ARRAY'){
Line 257 ⟶ 287:
return 0 if !defined($value);
return ($match eq $value) if !ref($match);
return $value=~/$match/ if(ref($match) eq 'Regexp');
if(ref($match) eq 'HASH'){
return 0 if ref($value) ne 'HASH';
my $ok=1;
while(my ($k,$v)
my $v2=exists($value->{$k})?$value->{$k}:undef;
$ok=($ok && _match($v,$v2));
|