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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: TFATitleSubpageCreator: * Comment out new code for now, can't work at that title due to missing OAuth grants.
AnomieBOT (talk | contribs)
Updating published sources: TFATitleSubpageCreator: * Supplemental BRFA filed. * Uncomment new code but guard it. * Update JSON format, and avoid overwriting if a human set a future entry to an array.
Line 1:
{{ombox|type=notice|text= Approved 2010-05-31<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT II]]}}
{{ombox|type=notice|text= First supplemental BFRA<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT II 4]]}}
<syntaxhighlight lang="perl">
package tasks::TFATitleSubpageCreator;
Line 11 ⟶ 12:
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT II
Status: Approved 2010-05-31
+BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT II 4
+Status: Awaiting approval
Created: 2010-05-26
 
Line 26 ⟶ 29:
use vars qw/@ISA/;
@ISA=qw/AnomieBOT::Task/;
 
my $jsontitle = undef;
 
sub new {
Line 38 ⟶ 43:
=for info
Approved 2010-05-31<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT II]]
 
=for info
First supplemental BFRA<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT II 4]]
 
=cut
Line 51 ⟶ 59:
$api->task('TFATitleSubpageCreator', 0, 10, qw/d::Talk d::Templates/);
 
#my ( $jsontok =, $api->edittoken( 'User:AnomieBOT II/TFA title.json' );
#my @jsonupdates = ();
#if($jsontok->{'code'} eq 'shutoff'){
#if ( $@jsontitle ) {
# $api->warn("Task disabled: ".$jsontok->{'content'}."\n");
$jsontok = $api->edittoken( $jsontitle );
# return 300;
# if($jsontok->{'code'} eq 'shutoff'){
#}
#if $api->warn("Task disabled: ".$jsontok->{'codecontent'} ne 'success'."\n"){;
# return 300;
# $api->warn("Failed to get edit token for User:AnomieBOT II/TFA title.json: ".$jsontok->{'error'}."\n");
# return 300;}
if($jsontok->{'code'} ne 'success'){
#}
# $api->warn("TaskFailed disabledto get edit token for $jsontitle: ".$jsontok->{'contenterror'}."\n");
return 300;
# }
 
# eval { $json = JSON->new->decode( $jsontok->{'revisions'}[0]{'slots'}{'main'}{'*'} // '' ); };
#my $json;
#}if ( $@ ) {
#eval { $json = JSON->new->decode( $jsontok->{'revisions'}[0]{'slots'}{'main'}{'*'} // '' ); };
# $api->warn("Failed to parse User:AnomieBOT II/TFA title.json$jsontitle: $@\n");
#if ( $@ ) {
return 300;
# $api->warn("Failed to parse User:AnomieBOT II/TFA title.json: $@\n");
# return 300;}
#}
#my @jsonupdates = ();
 
my $broken = 0;
Line 149 ⟶ 159:
}
 
#if ( $jsontitle ) {
my $dt = Time::Piece->strptime( $date, '%B %d, %Y' )->strftime( '%Y-%m-%d' );
#if ( $link ne (my $cur = $json->{'titles'}{$dt} // '' ) ) {;
# if ( ref( $json->{$dt}cur =) eq '' && $link; ne $cur ) {
# push @jsonupdates, "[[ $title|json->{'titles'}{$dt]]} is= [[$link]]";
push @jsonupdates, "[[$title|$dt]] is [[$link]]";
#}
}
# }
}
 
#if ( @jsonupdates ) {
# my $outtxt = JSON->new->pretty->canonical->encode( $json );
# my $r = $api->edit( $jsontok, $outtxt, "Updates: " . join( '; ', @jsonupdates ), 1, 1 );
# if ( $r->{'code'} ne 'success' ) {
# $api->warn( "Write failed on User:AnomieBOT II/TFA title.json$jsontitle: " . $r->{'error'} . "\n" );
# $broken = 1;
# }
#}
 
@titles=();