Rosetta Code:Village Pump/Lang-tag bot/Source: Difference between revisions
Rosetta Code:Village Pump/Lang-tag bot/Source (view source)
Revision as of 15:55, 15 November 2009
, 14 years agoImplemented kill switch.
Underscore (talk | contribs) (Created page with '<lang perl>use warnings; use strict; use feature 'say'; use List::Util '&minstr'; use HTML::Entities '&decode_entities'; use MediaWiki::API; use constant DELAY_BETWEEN_EDITS => …') |
Underscore (talk | contribs) (Implemented kill switch.) |
||
Line 6:
use MediaWiki::API;
use constant DELAY_BETWEEN_EDITS =>
my $username = 'UnderBot';
my $password = 'secret';
my $kill_switch_page = 'User talk:UnderBot';
my $kill_switch_trigger = qr/stopediting/;
my $tasks_list_path = '/home/hippo/Temporary/tasks';
Line 193 ⟶ 199:
my $mw = new MediaWiki::API({api_url => 'http://rosettacode.org/mw/api.php'});
$mw->login({lgname =>
or die q(Couldn't log in.);
Line 199 ⟶ 205:
{my $pagetitle = shift @titles;
say "TITLE: $pagetitle";
sleep DELAY_BETWEEN_EDITS;▼
# Check the kill switch.
my $p = $mw->get_page({title => $pagetitle}) || die;▼
my $p = $mw->get_page({title => $kill_switch_page}) || die;
$p->{'*'} =~ $kill_switch_trigger and die "Killed.\n";
my $timestamp = $p->{timestamp}; # To prevent edit conflicts.
my $text = $p->{'*'};
Line 301 ⟶ 311:
# Probably an edit conflict.
{say "Couldn't commit; I'll try again later.";
push @titles, $pagetitle;}
▲ sleep DELAY_BETWEEN_EDITS;}</lang>
|