Add killpage support
This commit is contained in:
parent
79a833133c
commit
37129d3833
3 changed files with 34 additions and 2 deletions
|
|
@ -1,12 +1,23 @@
|
|||
import {MediaWikiClient} from './api/mediawiki.js';
|
||||
|
||||
/**
|
||||
* Creates a mediawiki client with config pulled from environment variables.
|
||||
* @param {object} options
|
||||
* @param {stromg} [options.unattended] If provided, the page specified by the
|
||||
* `MW_KILLPAGE` environment variable will be checked periodically, and the
|
||||
* script will be killed if the page contains text. This is a safety measure
|
||||
* allowing other editors to kill an unattended script if it misbehaves.
|
||||
* @returns {Promise<MediaWikiClient>}
|
||||
*/
|
||||
export async function getMediawikiClient () {
|
||||
if (!process.env.MW_USERNAME || !process.env.MW_PASSWORD) {
|
||||
throw new Error('Environment variables `MW_USERNAME` and `MW_PASSWORD` are required.');
|
||||
}
|
||||
|
||||
// Log into our wiki client
|
||||
const mw = new MediaWikiClient('https://ffxiv.consolegameswiki.com/mediawiki');
|
||||
const mw = new MediaWikiClient('https://ffxiv.consolegameswiki.com/mediawiki', {
|
||||
killPage: process.env.MW_KILLPAGE || undefined,
|
||||
});
|
||||
await mw.login(process.env.MW_USERNAME, process.env.MW_PASSWORD);
|
||||
return mw;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue