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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: SourceUploader: * Sort directory pages by last modified date. * Use <nowiki><syntaxhighlight></nowiki> instead of <nowiki><source></nowiki>. d::NoWiki: * Add support for <nowiki><syntaxhighlight></nowiki>. General: * Vario
AnomieBOT (talk | contribs)
Updating published sources: ACNClerk: * New task. MedComClerk: * New task, on hold until User:AGK gets me the account info. CHUUClerk: * Fix typo that made the bot not correctly handle unregistered usernames. DeletionSortingCleaner: * Adjust meta
Line 27:
@ISA=qw/AnomieBOT::Task/;
 
use Storable qw/dclone/;
use Pod::Simple::Wiki;
use tasks::SourceUploader::Pod;
Line 90 ⟶ 91:
$self->{'summary'}=$self->{'summary'};
 
my $mainbot="\x02BOT\x03";
my %pages=();
my %tasks=(''=>{
'01 Current' => [],
'05 Awaiting approval' => [],
'06 Past' => [],
});
$tasks{'TaskList'}=dclone($tasks{''});
my @dirs=($basedir);
$self->{'shutoff_pages'}=[];
Line 160 ⟶ 163:
$x.="|- valign=\"top\"\n";
my $task=$metadata{'task'};
my $mainbotbot=$metadata{'bot'} // "\x02BOTx02!!!\x03";
my $botx.=$metadata"{'bot'{#if:{{{noacct|}}}||{{!}}align=\"center\"{{!}} // [[User:$mainbotbot|$bot]]}}\n";
$x.="|align=\"center\"| [[User:$bot|$bot]]\n";
$x.="|align=\"center\"| [[User:$mainbot/source$pp|$task]]\n";
if(exists($metadata{'shutoff'}) && $metadata{'shutoff'} eq 'false'){
Line 187 ⟶ 189:
$x.="<p style=\"margin:0;padding:0;font-size:smaller\">Supplemental:<br />\n";
for(my $i=0; $i<@{$metadata{'+brfa'}}; $i++){
my $x.s="+ \x5b\x5b".$metadata{'+brfa'}[$i].'|'.$metadata{'+status'}[$i]."\x5d\x5d<br />\n";
$s=$1 if $s=~/^Approved (\d{4}-\d{2}-\d{2})$/;
$x.="+ \x5b\x5b".$metadata{'+brfa'}[$i].'|'.$s."\x5d\x5d<br />\n";
}
$x.="</p>\n";
Line 197 ⟶ 201:
$pages{"$pp/metadata"}=$x;
my $section=determine_task_section(".$pp", %metadata);
$tasks{"TaskList"}{$section}//=[] unless exists($tasks{$section});
push @{$tasks{"TaskList"}{$section}}, $metadata{'created'}." {{User:$mainbot/source$pp/metadata}}";
$tasks{"TaskList/$bot"}//=dclone($tasks{''});
$x.=tasks{"|align=\"center\"| [[User:TaskList/$bot|"}{$botsection}//=[]]\n";
push @{$tasks{"TaskList/$bot"}{$section}}, $metadata{'created'}." {{User:$mainbot/source$pp/metadata|noacct=1}}";
}
}
Line 234 ⟶ 241:
}
 
my %tasklists=();
my $tasklist="<noinclude>\nThis page lists basic information about every task coded for this bot, including links to the bot approval and individual shutoff pages.\n\n== Tasks ==\n</noinclude>";
foreach my $sectionpg (sort keys %tasks) {
mynext @links=sortif @{$tasks{$section}}pg eq '';
$section=~s/^my (\d+$tl,$acct) //;
my if($npg=~/^TaskList\/(.*)$1;/){
$tl="<noinclude>\nThis page lists basic information about every task coded for [[User:$1|$1]], including links to the bot approval and individual shutoff pages. For the full list of tasks for all associated bot accounts, see [[User:$mainbot/TaskList]].\n\n== Tasks ==\n</noinclude>";
$tasklist.="\n=== $section ===\n";
if(@links){ $acct='';
$tasklist.="{| class=\"wikitable sortable\"\n";
$tasklist.="! Account !! Task !! Disable !! {{tlx|bots}} !! ".(($n==1 || $n==2)?'Approval':'Status')." !! Description\n";
$tasklist.=join("\n", map { substr($_,11) } @links)."\n";
$tasklist.="|}\n";
} else {
my $tasklisttl="<noinclude>\nThis page lists basic information about every task coded for thisall $mainbot botbots, including links to the bot approval and individual shutoff pages.\n\n== Tasks ==\n</noinclude>";
$tasklist.="None at this time.\n";
$acct='! Account !';
}
foreach my $section (sort keys %{$tasks{$pg}}){
my @links=sort @{$tasks{$pg}{$section}};
$section=~s/^(\d+) //;
my $n=$1;
$tasklisttl.="\n=== $section ===\n";
if(@links){
$tasklisttl.="{| class=\"wikitable sortable\"\n";
$tasklisttl.="! Account !$acct! Task !! Disable !! {{tlx|bots}} !! ".(($n==1 || $n==2)?'Approval':'Status')." !! Description\n";
$tasklisttl.=join("\n", map { substr($_,11) } @links)."\n";
$tasklisttl.="|}\n";
} else {
$tasklisttl.="None at this time.\n";
}
}
$tasklists{$pg}=$tl;
}
 
$self->{'pages'}={%pages};
$self->{'tasklisttasklists'}=$tasklist\%tasklists;
return $self;
}
Line 259 ⟶ 278:
 
my @keys=keys(%{$self->{'pages'}});
my @tlkeys=keys(%{$self->{'tasklists'}});
my @shutoff=@{$self->{'shutoff_pages'}};
if(!@keys && !@shutofftlkeys && !exists($self->{'tasklist'})@shutoff){
$api->debug(2, "Source uploaded, terminating");
return undef;
Line 309 ⟶ 329:
}
 
while(@tlkeys){
if(exists($self->{'tasklist'})){
my $page=shift @tlkeys;
my $ret=$self->upload_page($api, 'User:'.$api->user.'/TaskList', $self->{'tasklist'});
my $text=$self->{'tasklists'}{$page};
my $ret=$self->upload_page($api, 'User:'.$api->user.'"/TaskList'$page", $self->{'tasklist'}text);
return $ret if $ret>60;
delete(next if $self-ret>{'tasklist'})0;
delete($self->{'tasklists'}{$page});
}