forked from MediaWiki-Bot/MediaWiki-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a new bot
Mike.lifeguard edited this page Aug 13, 2011
·
1 revision
Calling MediaWiki::Bot->new() will create a new MediaWiki::Bot object. The hashref is as follows:
-
agentsets a custom useragent. This should consist of the software used, the operator, and a link to contact information. For example,MediaWiki::Bot 3.0.0 (http://meta.wikimedia.org/wiki/User:Mike.lifeguard) -
assertsets a parameter for the AssertEdit extension (commonly 'bot'). Refer to http://mediawiki.org/wiki/Extension:AssertEdit -
operatorallows the bot to send you a message when it fails an assert, and will be integrated into the default useragent (which may not be used if you set agent yourself). The message will tell you that$useragentis logged out, so use a descriptive one if you set it. -
maxlagallows you to set the maxlag parameter (default is the recommended 5s). Please refer to the MediaWiki documentation prior to changing this from the default. -
protocolallows you to specify 'http' or 'https' (default is 'http'). This is commonly used with the domain and path settings below. -
hostsets the domain name of the wiki to connect to. -
pathsets the path to api.php (with no trailing slash). -
login_datais a hashref of data to pass to login(). See that section for a description.
For example:
my $bot = MediaWiki::Bot->new({
useragent => 'MediaWiki::Bot 3.0.0 (User:Mike.lifeguard)',
assert => 'bot',
protocol => 'https',
host => 'secure.wikimedia.org',
path => 'wikipedia/meta/w',
login_data => { username => "Mike's bot account", password => "password" },
});