MediaWiki-Bot
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
my $log = $bot->get_log({
type => 'block',
user => 'User:Mike.lifeguard',
});
foreach my $entry (@$log) {
my $user = $entry->{'title'};
print "$user\n";
}
$bot->get_log({
type => 'block',
user => 'User:Mike.lifeguard',
},
{ hook => \&mysub, max => 10 }
);
sub mysub {
my ($res) = @_;
foreach my $hashref (@$res) {
my $title = $hashref->{'title'};
print "$title\n";
}
}
**References:** [API:Logevents](https://www.mediawiki.org/wiki/API:Logevents)
## is\_g\_blocked
my $is_globally_blocked = $bot->is_g_blocked('127.0.0.1');
Returns what IP/range block _currently in place_ affects the IP/range. The
return is a scalar of an IP/range if found (evaluates to true in boolean
context); undef otherwise (evaluates false in boolean context). Pass in a
single IP or CIDR range.
**References:** [Extension:GlobalBlocking](https://www.mediawiki.org/wiki/Extension:GlobalBlocking/API)
## was\_g\_blocked
print "127.0.0.1 was globally blocked\n" if $bot->was_g_blocked('127.0.0.1');
Returns whether an IP/range was ever globally blocked. You should probably
call this method only when your bot is operating on Meta - this method will
warn if not.
**References:** [API:Logevents](https://www.mediawiki.org/wiki/API:Logevents)
## was\_locked
my $was_locked = $bot->was_locked('Mike.lifeguard');
Returns whether a user was ever locked. You should probably call this method
only when your bot is operating on Meta - this method will warn if not.
**References:** [API:Logevents](https://www.mediawiki.org/wiki/API:Logevents)
## get\_protection
Returns data on page protection as a array of up to two hashrefs. Each hashref
has a type, level, and expiry. Levels are 'sysop' and 'autoconfirmed'; types are
'move' and 'edit'; expiry is a timestamp. Additionally, the key 'cascade' will
exist if cascading protection is used.
my $page = 'Main Page';
$bot->edit({
page => $page,
text => rand(),
summary => 'test',
}) unless $bot->get_protection($page);
You can also pass an arrayref of page titles to do bulk queries:
my @pages = ('Main Page', 'User:Mike.lifeguard', 'Project:Sandbox');
my $answer = $bot->get_protection(\@pages);
foreach my $title (keys %$answer) {
my $protected = $answer->{$title};
print "$title is protected\n" if $protected;
print "$title is unprotected\n" unless $protected;
}
**References:** [API:Properties#info](https://www.mediawiki.org/wiki/API:Properties#info_.2F_in)
## is\_protected
This is a synonym for ["get\_protection"](#get_protection), which should be used in preference.
**This method is deprecated**, and will emit deprecation warnings.
## patrol
$bot->patrol($rcid);
Marks a page or revision identified by the $rcid as patrolled. To mark several
RCIDs as patrolled, you may pass an arrayref of them. Returns false and sets
`$bot->{error}` if the account cannot patrol.
**References:** [API:Patrol](https://www.mediawiki.org/wiki/API:Patrol)
## email
$bot->email($user, $subject, $body);
This allows you to send emails through the wiki. All 3 of $user (without the
User: prefix), $subject and $body are required. If $user is an arrayref, this
will send the same email (subject and body) to all users.
**References:** [API:Email](https://www.mediawiki.org/wiki/API:Email)
## top\_edits
Returns an array of the page titles where the $user is the latest editor. The
second parameter is the familiar [$options\_hashref](#linksearch).
my @pages = $bot->top_edits("Mike.lifeguard", {max => 5});
foreach my $page (@pages) {
$bot->rollback($page, "Mike.lifeguard");
}
Note that accessing the data with a callback happens **before** filtering
the top edits is done. For that reason, you should use ["contributions"](#contributions)
if you need to use a callback. If you use a callback with top\_edits(),
( run in 0.599 second using v1.01-cache-2.11-cpan-39bf76dae61 )