User

BPWelcomeBot/Source

From Beachapedia

< User:BPWelcomeBot

Source Code for BPWelcomeBot

Note Note: This code was updated 2/22/2011 to use the new (3.2.7) version of the MediaWiki::Bot perl module. Earlier versions of the module will not work with this code
#!/usr/bin/perl

use MediaWiki::Bot;

my $bot = MediaWiki::Bot->new({
	protocol	=>	'http',
	host		=>	'www.beachapedia.org',
	path		=> 	'',
});
$bot->login({
        username => "BPWelcomeBot",
        password => "REDACTED",
});

@editors = $bot->get_allusers('500', 'editors');


foreach $username (@editors) {
my $pageid = $bot->get_id("User_talk:$username");
     if (defined($pageid)){
	} else {
 $text = "\=\=Welcome Message\=\=\n\n\{\{New Editor\}\}\n\n--\~\~\~\~\n";
    $bot->edit({
        page    => "User_talk:$username",
        text    => $text,
        summary => 'BPWelcomeBot adding "New Editor" information',
    });
	}
}

$bot->logout();