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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: TemplateSubster: * Split logic into a "base" class, to share with the new TFDTemplateSubster. TFDTemplateSubster: * New task!
 
AnomieBOT (talk | contribs)
Updating published sources: TFDTemplateSubster: * Don't do <code>JSON->utf8</code>. AnomieBOT::API returns and expects Unicode strings, not utf8-encoded strings.
 
(2 intermediate revisions by the same user not shown)
Line 1:
{{ombox|type=notice|text= ApprovalApproved requested2020-02-02<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 78]]}}
<syntaxhighlight lang="perl">
package tasks::TFDTemplateSubster;
Line 10:
Task: TFDTemplateSubster
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 78
Status: BRFAApproved 2020-02-02
Created: 2020-01-31
 
Line 44:
 
=for info
ApprovalApproved requested2020-02-02<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 78]]
 
=cut
 
sub approved {
return 03;
}
 
Line 141:
$api->warn( "Failed to get redirects: " . $r{''}{'error'} . "\n" );
return 60;
}
 
# Handle normalizations, e.g. underscore to space.
while ( my ( $r, $t ) = each( %r ) ) {
if ( defined( $workList{$r} ) && !defined( $workList{$t} ) ) {
$workList{$t} = $workList{$r};
delete $workList{$r};
}
}
 
Line 162 ⟶ 170:
if ( $status->[0] < $revid ) {
eval {
$status->[1] = JSON->new->utf8->decode( $tok->{'revisions'}[0]{'slots'}{'main'}{'*'} // '' );
};
$status->[1] = {} unless ref( $status->[1] ) eq 'HASH';
Line 186 ⟶ 194:
if ( $writeStatus ) {
$api->log( "Updating processing status page" );
my $outtxt = JSON->new->utf8->pretty->canonical->encode( \%process );
my $res2 = $api->edit( $tok, $outtxt, 'Updating status page', 1, 1, contentmodel => 'json' );
if ( $res2->{'code'} eq 'success' ) {