User:Pibot/Blocking script

From RationalWiki
Jump to: navigation, search
use MediaWiki::API;
use MediaWiki::Bot;
 
$user = 'Pibot'; my $pass = '******';
$editor=MediaWiki::Bot->new($user);
 
$editor->set_wiki('rationalwiki.com','wiki');
 
$editor->login($user,$pass);
 
my $mw = MediaWiki::API->new( {
   api_url => 'http://rationalwiki.com/wiki/api.php' }  );
 $mw->login( { lgname => $user, lgpassword => $pass } ) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details};
 
my $AoH=$mw->list({action => 'query',
		list => 'allusers',
		augroup => 'sysop',
		aulimt => 5000});
 
    for $href ( @$AoH ) {
        for $role ( values %$href ) {
             $test=$editor->test_blocked($user);
                  if($test>0){
                     $editor->unblock($user);
                    }
             $name=$href->{name};
	     if($name ne $user){
		$editor->block($name,'314 seconds', 'Pibot is the greatest blocker ever', 0, 0, 0, 0);
	     }
        }
    }
Personal tools
Namespaces

Variants
Actions
Navigation
Community
Tools
support