1 const MWBot
= require( 'mwbot' );
3 // TODO: Once we require Node 7 or later, we can use async-await.
7 * Shortcut for `MWBot#edit( .. )`.
10 * @see <https://www.mediawiki.org/wiki/API:Edit>
11 * @param {string} title
12 * @param {string} content
13 * @return {Object} Promise for API action=edit response data.
15 edit( title
, content
) {
16 let bot
= new MWBot();
18 return bot
.loginGetEditToken( {
19 apiUrl
: `${browser.options.baseUrl}/api.php`,
20 username
: browser
.options
.username
,
21 password
: browser
.options
.password
22 } ).then( function () {
23 return bot
.edit( title
, content
, `Created page with "${content}"` );
28 * Shortcut for `MWBot#delete( .. )`.
31 * @see <https://www.mediawiki.org/wiki/API:Delete>
32 * @param {string} title
33 * @param {string} reason
34 * @return {Object} Promise for API action=delete response data.
36 delete( title
, reason
) {
37 let bot
= new MWBot();
39 return bot
.loginGetEditToken( {
40 apiUrl
: `${browser.options.baseUrl}/api.php`,
41 username
: browser
.options
.username
,
42 password
: browser
.options
.password
43 } ).then( function () {
44 return bot
.delete( title
, reason
);
49 * Shortcut for `MWBot#request( { acount: 'createaccount', .. } )`.
52 * @see <https://www.mediawiki.org/wiki/API:Account_creation>
53 * @param {string} username
54 * @param {string} password
55 * @return {Object} Promise for API action=createaccount response data.
57 createAccount( username
, password
) {
58 let bot
= new MWBot();
61 return bot
.loginGetCreateaccountToken( {
62 apiUrl
: `${browser.options.baseUrl}/api.php`,
63 username
: browser
.options
.username
,
64 password
: browser
.options
.password
65 } ).then( function () {
66 // Create the new account
68 action
: 'createaccount',
69 createreturnurl
: browser
.options
.baseUrl
,
70 createtoken
: bot
.createaccountToken
,