Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions tools/autowiki/autowiki.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
const fs = require("fs").promises;
const MWBot = require("mwbot");
const fs = require('fs').promises;
const MWBot = require('mwbot');

const { USERNAME, PASSWORD } = process.env;

if (!USERNAME) {
console.error("USERNAME was not set.");
console.error('USERNAME was not set.');
process.exit(1);
}

if (!PASSWORD) {
console.error("PASSWORD was not set.");
console.error('PASSWORD was not set.');
process.exit(1);
}

const PAGE_EDIT_FILENAME = process.argv[2];

if (!PAGE_EDIT_FILENAME) {
console.error("No filename specified to edit pages");
console.error('No filename specified to edit pages');
process.exit(1);
}

const FILE_EDIT_FILENAME = process.argv[3];

if (!FILE_EDIT_FILENAME) {
console.error("No filename specified to edit files");
console.error('No filename specified to edit files');
process.exit(1);
}

async function main() {
console.log(`Reading from ${PAGE_EDIT_FILENAME}`);
const editFile = await (
await fs.readFile(PAGE_EDIT_FILENAME, "utf8")
).split("\n");
const editFile = await (await fs.readFile(PAGE_EDIT_FILENAME, 'utf8')).split(
'\n',
);

console.log(`Logging in as ${USERNAME}`);

const bot = new MWBot();

await bot.loginGetEditToken({
apiUrl: "https://wiki.tgstation13.org/api.php",
apiUrl: 'https://wiki.pmeta.space/api.php',
username: USERNAME,
password: PASSWORD,
});

console.log("Logged in");
console.log('Logged in');

// This is not Promise.all as to not flood with a bunch of traffic at once
for (const editLine of editFile) {
Expand All @@ -53,7 +53,7 @@ async function main() {

let { title, text } = JSON.parse(editLine);
text =
"<noinclude><b>This page is automated by Autowiki. Do NOT edit it manually.</b></noinclude>" +
'<noinclude><b>This page is automated by Autowiki. Do NOT edit it manually.</b></noinclude>' +
text;

console.log(`Editing ${title}...`);
Expand All @@ -73,7 +73,7 @@ async function main() {
`Autowiki upload @ ${new Date().toISOString()}`,
)
.catch((error) => {
if (error.code === "fileexists-no-change") {
if (error.code === 'fileexists-no-change') {
console.log(`${assetName} is an exact duplicate`);
} else {
return Promise.reject(error);
Expand Down
Loading