Rosetta Code:Village Pump/Lang-tag bot/Source: Difference between revisions

Changed to persistently keep track of which pages have been edited and to tag APL. Added to Category:Perl.
(Implemented kill switch.)
(Changed to persistently keep track of which pages have been edited and to tag APL. Added to Category:Perl.)
Line 4:
use List::Util '&minstr';
use HTML::Entities '&decode_entities';
use YAML::XS qw(&DumpFile &LoadFile);
use MediaWiki::API;
 
Line 14 ⟶ 15:
my $kill_switch_trigger = qr/stopediting/;
 
my $tasks_list_pathtasks_path = '/home/hippo/Temporary/tasks.yml';
 
my %langtags = (
Line 24 ⟶ 25:
'algol 68' => 'algol68',
'amigae' => 'amigae',
#'apl' => 'apl',
'applescript' => 'applescript',
'assembly' => 'asm',
Line 193 ⟶ 194:
# ------------------------------------------------------------
 
openour my $(%tasks, '<:utf8'@done, $tasks_list_path@todo);
local *tasks = LoadFile $tasks_path;
or die qq(Couldn't read "$tasks_list_path".\n($!)\n);
mylocal @titles*done = <$tasks>{done};
local *todo = $tasks{todo};
s/\s+\z// foreach @titles;
 
my $mw = new MediaWiki::API({api_url => 'http://rosettacode.org/mw/api.php'});
Line 202 ⟶ 203:
or die q(Couldn't log in.);
 
while (@titlestodo)
{my $pagetitle = shift @titlestodo;
say "TITLE: $pagetitle";
 
Line 307 ⟶ 308:
 
if ($success)
{say 'Committed!';}
push @done, $pagetitle;}
else
# Probably an edit conflict.
{say "Couldn't commit; I'll try again later.";
push @titlestodo, $pagetitle;}
DumpFile $tasks_path, \%tasks;
 
sleep DELAY_BETWEEN_EDITS;}</lang>
 
[[Category:Perl]]
845

edits