User:Polbot/source/Use Polbot 1.p1

From Wikipedia, the free encyclopedia

use strict;
use Q::Polbot;
use Perlwikipedia;

print "\nStarting polbot\n" ;
my $pw=Perlwikipedia->new();
#$pw->{debug} = 1;
$pw->{mech}->agent('Bot/WP/EN/Quadell/polbot');

print "Logging in\n";
my $login_status=$pw->login('bot name','bot password');
die "I can't log in." unless ($login_status eq 0);

my @reps = ();
print "Opening rep list\n";
my $replist = $pw->get_text('User:Polbot/fullreplist');
my @lines = split(/\n/, $replist);
foreach my $line (@lines) {
        if ($line =~ m/^\*\s*\[\[(.*)\]\]$/) {
                push @reps, $1;
        }
}

print "Processing\n";
foreach my $name (@reps) {
        print "$name : ";
        my $url = Polbot::Get_URL_from_name($name);
        print "$url\n";
        if ($url =~ m/^http/) {
                my $wiki_code = Polbot::bio2wiki($url);
                
                $pw->edit($name, $wiki_code, "Auto-generating new article based on $url");
                $pw->edit("Talk:$name", "{{WPBiography|class=start|priority=low|needs-infobox=yes|politician-work-group=yes}}", "Auto-adding WPbiography template");

                print "Article created.";
                print "\n";
                sleep 15;
        }
}

print "\nDone.\n";