Rosetta Code:Village Pump/Lang-tag bot/Source: Difference between revisions
Content added Content deleted
Underscore (talk | contribs) (Changed to persistently keep track of which pages have been edited and to tag APL. Added to Category:Perl.) |
Underscore (talk | contribs) m (Minor updates.) |
||
Line 201: | Line 201: | ||
my $mw = new MediaWiki::API({api_url => 'http://rosettacode.org/mw/api.php'}); |
my $mw = new MediaWiki::API({api_url => 'http://rosettacode.org/mw/api.php'}); |
||
$mw->login({lgname => $username, lgpassword => $password}) |
$mw->login({lgname => $username, lgpassword => $password}) |
||
or die q |
or die q{Couldn't log in. (}, $mw->{error}->{code}, ': ', |
||
$mw->{error}->{details}, ')'; |
|||
while (@todo) |
while (@todo) |
||
Line 259: | Line 260: | ||
# indentation is probably intentional (as |
# indentation is probably intentional (as |
||
# in many J examples). |
# in many J examples). |
||
{my $space = minstr($b =~ /^( +)/gm); |
{my $space = minstr($b =~ /^( +)\S/gm); |
||
$b =~ s/^$space//gm;} |
$b =~ s/^$space//gm;} |
||
"$t$b\x3c/lang>"}xges;} |
"$t$b\x3c/lang>"}xges;} |
||
Line 278: | Line 279: | ||
$lwsl \n )? ) } |
$lwsl \n )? ) } |
||
{my $t = $1; |
{my $t = $1; |
||
my $space = minstr($t =~ /^( +)/gm); |
my $space = minstr($t =~ /^( +)\S/gm); |
||
$t =~ s/^$space//gm; |
$t =~ s/^$space//gm; |
||
$t =~ s/\s+\z//; |
$t =~ s/\s+\z//; |
||
Line 302: | Line 303: | ||
# If the page was deleted while we were regexing, |
# If the page was deleted while we were regexing, |
||
# we probably shouldn't resurrect it! |
# we probably shouldn't resurrect it! |
||
summary => 'Fixed lang tags |
summary => 'Fixed lang tags.'}, |
||
{skip_encoding => 1}); |
{skip_encoding => 1}); |
||
# Without the skip_encoding option, non-ASCII characters |
# Without the skip_encoding option, non-ASCII characters |
||
Line 308: | Line 309: | ||
if ($success) |
if ($success) |
||
{say |
{say(exists $success->{edit}->{nochange} |
||
? 'Unchanged.' |
|||
: 'Committed!'); |
|||
push @done, $pagetitle;} |
push @done, $pagetitle;} |
||
else |
else |