diff --git a/afd-notifications/notifier.ts b/afd-notifications/notifier.ts index 2289ff5..65a00ae 100644 --- a/afd-notifications/notifier.ts +++ b/afd-notifications/notifier.ts @@ -1,10 +1,10 @@ -import {bot, log, emailOnError, mwn, argv} from '../botbase'; +import {bot, log, emailOnError, Mwn, argv} from '../botbase'; const PercentDefault = 0.25; const ByteDefault = 1000; class Notifier { - table: InstanceType + table: InstanceType notificationScheme: Map> afds: { [afdtitle: string]: string } config: { @@ -22,7 +22,7 @@ class Notifier { await notifier.getAfDs(); - notifier.table = new mwn.table(); + notifier.table = new Mwn.table(); notifier.table.addHeaders([ `! scope="col" style="width: 14em" | AfD`, `! scope="col" style="width: 14em" | Article`, @@ -348,7 +348,7 @@ class Notifier { return Promise.reject('nobots'); } - let rgx = new RegExp(`== ?Nomination of \\[\\[:?${mwn.util.escapeRegExp(article)}\\]\\] for deletion ?==`); + let rgx = new RegExp(`== ?Nomination of \\[\\[:?${Mwn.util.escapeRegExp(article)}\\]\\] for deletion ?==`); if (rgx.test(text)) { log(`[C] ${username} was already notified of ${article}`); return Promise.reject('already-notified'); @@ -360,7 +360,7 @@ class Notifier { } } - if (!mwn.util.isIPAddress(username)) { // IP blocks can't be looked up this way, TODO: handle this + if (!Mwn.util.isIPAddress(username)) { // IP blocks can't be looked up this way, TODO: handle this let blockinfo = await user.info('blockinfo'); if (blockinfo.blockid) { // blocked if (blockinfo.blockexpiry === 'infinite') { diff --git a/bot-monitor/Alert.ts b/bot-monitor/Alert.ts index 087c1b8..d5e2f0f 100644 --- a/bot-monitor/Alert.ts +++ b/bot-monitor/Alert.ts @@ -1,4 +1,4 @@ -import { argv, bot, log, mwn } from "../botbase"; +import { argv, bot, log, Mwn } from "../botbase"; import {Rule, RuleError, Monitor} from "./index"; export class Alert { @@ -39,7 +39,7 @@ export class Alert { } getMessage() { - return mwn.template('subst:Wikipedia:Bot activity monitor/Notification', { + return Mwn.template('subst:Wikipedia:Bot activity monitor/Notification', { bot: this.rule.bot, task: this.rule.task, action: this.rule.action === 'edit' ? 'edit' : `"${this.rule.action}" action`, diff --git a/bot-monitor/Rule.ts b/bot-monitor/Rule.ts index 9f6e119..75af550 100644 --- a/bot-monitor/Rule.ts +++ b/bot-monitor/Rule.ts @@ -1,4 +1,4 @@ -import {argv, bot, mwn, path} from "../botbase"; +import {argv, bot, Mwn, path} from "../botbase"; import {MwnTitle, MwnDate} from "../../mwn"; import {getFromDate} from "./index"; import {readFile} from "../utils"; @@ -88,9 +88,9 @@ export function parseRule(rule: RawRule): Rule { namespace: rule.namespace && rule.namespace.match(/\d+/g).map(num => parseInt(num)), duration: rule.duration, fromDate, - titleRegex: (rule.title && new RegExp('^' + mwn.util.escapeRegExp(rule.title) + '$')) || + titleRegex: (rule.title && new RegExp('^' + Mwn.util.escapeRegExp(rule.title) + '$')) || (rule.title_regex && new RegExp('^' + rule.title_regex + '$')), - summaryRegex: (rule.summary && new RegExp('^' + mwn.util.escapeRegExp(rule.summary) + '$')) || + summaryRegex: (rule.summary && new RegExp('^' + Mwn.util.escapeRegExp(rule.summary) + '$')) || (rule.summary_regex && new RegExp('^' + rule.summary_regex + '$')), minEdits: rule.min_edits ? parseInt(rule.min_edits) : 1, alertPage diff --git a/bot-monitor/Tabulator.ts b/bot-monitor/Tabulator.ts index efaca35..aec1354 100644 --- a/bot-monitor/Tabulator.ts +++ b/bot-monitor/Tabulator.ts @@ -1,4 +1,4 @@ -import { bot, mwn, log, argv, enwikidb } from "../botbase"; +import { bot, Mwn, log, argv, enwikidb } from "../botbase"; import {Monitor} from './index'; import * as moment from "moment"; @@ -6,11 +6,11 @@ import * as moment from "moment"; export class Tabulator { static rootpage = 'Wikipedia:Bot activity monitor' + (argv.fake ? '/sandbox' : ''); - static table: InstanceType; + static table: InstanceType; static invalidRules: { task: string, reason: string }[] = [] static init() { - this.table = new mwn.table(); + this.table = new Mwn.table(); this.table.addHeaders([ {label: 'Bot'}, {label: 'Task'}, @@ -52,7 +52,7 @@ export class Tabulator { static async whineAboutRuleErrors() { let msg; if (this.invalidRules.length) { - let table = new mwn.table(); + let table = new Mwn.table(); table.addHeaders([ 'Bot and task', 'Configuration error' @@ -73,7 +73,7 @@ export class Tabulator { } catch (e) {} let text = '== Current status report ==' + (replagHours > 6 ? `Database replication lag is ${replagHours} hours; as a result some bots may not be working` : '') + - '' + mwn.template('/header', { + '' + Mwn.template('/header', { errcount: this.invalidRules.length ? String(this.invalidRules.length) : null }) + '\n' + Tabulator.table.getText(); if (argv.dry) { diff --git a/botbase.ts b/botbase.ts index d209c9e..a2fd4fa 100644 --- a/botbase.ts +++ b/botbase.ts @@ -46,11 +46,11 @@ process.on('uncaughtException', function(err) { } }); -import {mwn} from '../mwn'; -export {mwn}; +import {Mwn} from '../mwn'; +export {Mwn}; /** Colorised and dated console logging. */ -export const log = mwn.log; +export const log = Mwn.log; /** Parsed console arguments */ export const argv = require('minimist')(process.argv.slice(2)); @@ -68,7 +68,7 @@ export class AuthManager { } } -export const bot = new mwn({ +export const bot = new Mwn({ apiUrl: 'https://en.wikipedia.org/w/api.php', ...AuthManager.get('SDZeroBot:oauth2'), ...AuthManager.get('SDZeroBot:bp1'), diff --git a/check-webservice.ts b/check-webservice.ts index ae2f934..7b57e68 100644 --- a/check-webservice.ts +++ b/check-webservice.ts @@ -1,8 +1,8 @@ -import { emailOnError, mwn } from './botbase'; +import { emailOnError, Mwn } from './botbase'; process.chdir(__dirname + '/webservice'); -new mwn().rawRequest({ +new Mwn().rawRequest({ url: 'https://sdzerobot.toolforge.org/ping' }).then(response => { let data = response?.data; diff --git a/db-tabulator/app.ts b/db-tabulator/app.ts index da4ba3b..37f4cf3 100644 --- a/db-tabulator/app.ts +++ b/db-tabulator/app.ts @@ -1,4 +1,4 @@ -import { argv, bot, emailOnError, log, mwn, TextExtractor } from "../botbase"; +import { argv, bot, emailOnError, log, Mwn, TextExtractor } from "../botbase"; import { enwikidb, SQLError } from "../db"; import { Template } from "../../mwn/build/wikitext"; import { arrayChunk, createLogStream, lowerFirst, readFile, writeFile } from "../utils"; @@ -458,10 +458,10 @@ export class Query { const header_template = this.getTemplateValue('header_template'); const skip_table = this.getTemplateValue('skip_table'); - let table: InstanceType; + let table: InstanceType; let tableText = ''; if (!skip_table) { - table = new mwn.table({ + table = new Mwn.table({ style: this.getTemplateValue('table_style') || 'overflow-wrap: anywhere' }); if (header_template) { @@ -516,7 +516,7 @@ export class Query { db.makeReplagMessage(2) + tableText + '\n' + '----\n' + - mwn.template('Database report/footer', { + Mwn.template('Database report/footer', { count: result.length, page: pageNumber && String(pageNumber), num_pages: pageNumber && String(this.numPages), diff --git a/experiments/rich-statistics/num-active-editors.js b/experiments/rich-statistics/num-active-editors.js index af534fc..abb48d9 100644 --- a/experiments/rich-statistics/num-active-editors.js +++ b/experiments/rich-statistics/num-active-editors.js @@ -1,4 +1,4 @@ -const {bot, mwn, log} = require('../../botbase'); +const {bot, Mwn, log} = require('../../botbase'); (async function() { @@ -28,7 +28,7 @@ for (let i = userswithcount.length - 1; i >= 0; i--) { userswithcount[i] = orz(userswithcount[i+1]) + orz(userswithcount[i]); } -let table = new mwn.table(); +let table = new Mwn.table(); table.addHeaders([ {label: 'Statistic', style: 'width: 40em;'}, {label: 'Value', style: 'width: 20em'} @@ -43,7 +43,7 @@ table.addRow([ 'Users with 500+ actions in the last 30 days', orz(userswithcount table.addRow([ 'Users with 1000+ actions in the last 30 days', orz(userswithcount[1000]) ]); table.addRow([ 'Users with 5000+ actions in the last 30 days', orz(userswithcount[5000]) ]); -let wikitext = +let wikitext = `{{hatnote|Last updated by [[User:SDZeroBot|SDZeroBot]] at ~~~~~}} ${table.getText()} @@ -56,4 +56,4 @@ await bot.save('User:SDZeroBot/Number of active editors', wikitext, 'Updating'); log(`[i] Finished`); -})(); \ No newline at end of file +})(); diff --git a/most-gans/gans-lister.ts b/most-gans/gans-lister.ts index 392c62f..dc192e2 100644 --- a/most-gans/gans-lister.ts +++ b/most-gans/gans-lister.ts @@ -1,4 +1,4 @@ -import { argv, bot, log, mwn } from '../botbase'; +import { argv, bot, log, Mwn } from '../botbase'; import { TOOLS_DB_HOST, toolsdb } from '../db'; import { closeTunnels, createLocalSSHTunnel, withIndices } from "../utils"; import { TABLE } from "./model"; @@ -17,7 +17,7 @@ import { TABLE } from "./model"; db.end(); log(`[S] Got query result`); - let wikitable = new mwn.table(); + let wikitable = new Mwn.table(); wikitable.addHeaders(['Rank', 'User', 'Count']); let rank500Count; diff --git a/one-time/books.ts b/one-time/books.ts index df27819..b4390c5 100644 --- a/one-time/books.ts +++ b/one-time/books.ts @@ -1,4 +1,4 @@ -import { argv, bot, log, mwn } from '../botbase'; +import { argv, bot, log, Mwn } from '../botbase'; import { enwikidb, ENWIKI_DB_HOST } from "../db"; import { createLocalSSHTunnel, readFile, saveObject, writeFile } from "../utils"; @@ -93,7 +93,7 @@ import { createLocalSSHTunnel, readFile, saveObject, writeFile } from "../utils" // }) // } - let wikitable = new mwn.table({ + let wikitable = new Mwn.table({ classes: ['plainlinks'] }); wikitable.addHeaders([ @@ -106,9 +106,9 @@ import { createLocalSSHTunnel, readFile, saveObject, writeFile } from "../utils" title = 'Book:' + title.replace(/_/g, ' '); wikitable.addRow([ `[[${title}]]`, - `[https://en.wikipedia.org/w/index.php?title=${mwn.util.wikiUrlencode(title)}&action=history ${num_revisions}]`, + `[https://en.wikipedia.org/w/index.php?title=${Mwn.util.wikiUrlencode(title)}&action=history ${num_revisions}]`, num_editors, - `[https://en.wikipedia.org/w/index.php?title=${mwn.util.wikiUrlencode(title)}&action=info ${pageviews}]` + `[https://en.wikipedia.org/w/index.php?title=${Mwn.util.wikiUrlencode(title)}&action=info ${pageviews}]` ]); } diff --git a/one-time/feature-historian.ts b/one-time/feature-historian.ts index 25cd94e..02436be 100644 --- a/one-time/feature-historian.ts +++ b/one-time/feature-historian.ts @@ -1,4 +1,4 @@ -import {bot, fs, log, mwn} from '../botbase.js'; +import {bot, fs, log, Mwn} from '../botbase.js'; (async function () { @@ -90,7 +90,7 @@ for await (let pg of reader) { } -let mwntable = new mwn.table({ +let mwntable = new Mwn.table({ style: 'overflow-wrap: anywhere;' }); mwntable.addHeaders([ diff --git a/reports/afc-sorting/afc-sorting.js b/reports/afc-sorting/afc-sorting.js index e2b59b6..e77ac14 100644 --- a/reports/afc-sorting/afc-sorting.js +++ b/reports/afc-sorting/afc-sorting.js @@ -1,4 +1,4 @@ -const {fs, mwn, bot, enwikidb, utils, argv, log, emailOnError} = require('../../botbase'); +const {fs, Mwn, bot, enwikidb, utils, argv, log, emailOnError} = require('../../botbase'); const OresUtils = require('../OresUtils'); const {createLocalSSHTunnel, closeTunnels} = require("../../utils"); const {ENWIKI_DB_HOST} = require("../../db"); @@ -86,7 +86,7 @@ process.chdir(__dirname); var entriesFound = 0; var getCopyioPercent = function(title) { - var re = new RegExp(`${mwn.util.escapeRegExp(title).replace(/ /g, '_')}(?:\\s|\\S)*?tools\\.wmflabs\\.org\\/copyvios\\/.*? (.*?)\\]%`).exec(UserSQLReport); + var re = new RegExp(`${Mwn.util.escapeRegExp(title).replace(/ /g, '_')}(?:\\s|\\S)*?tools\\.wmflabs\\.org\\/copyvios\\/.*? (.*?)\\]%`).exec(UserSQLReport); if (!re || !re[1]) { return null; } @@ -280,7 +280,7 @@ process.chdir(__dirname); } content += `{{Wikipedia:AfC sorting/header|count=${sorter[topic].length}|date=${accessdate}|ts=~~~~~}}\n${replagMessage}`; - var table = new mwn.table(); + var table = new Mwn.table(); table.addHeaders([ `scope="col" style="width: 17em;" | Page`, `Class`, @@ -307,7 +307,7 @@ process.chdir(__dirname); editorString = `[[Special:Contribs/${tabledata.creator}|${tabledata.creator}]] (${tabledata.creatorEdits})`; } else { // lowercase IPv6 address and split to 2 lines to reduce column width - if (mwn.util.isIPv6Address(tabledata.creator)) { + if (Mwn.util.isIPv6Address(tabledata.creator)) { var ip = tabledata.creator.toLowerCase(); var idx = Math.round(ip.length / 2); ip = ip.slice(0, idx) + '
' + ip.slice(idx); diff --git a/reports/afd-sorting/afd-sorting-beta.js b/reports/afd-sorting/afd-sorting-beta.js index 74b6584..52d2e7e 100644 --- a/reports/afd-sorting/afd-sorting-beta.js +++ b/reports/afd-sorting/afd-sorting-beta.js @@ -1,4 +1,4 @@ -const {mwn, bot, log, argv, utils, emailOnError} = require('../../botbase'); +const {Mwn, bot, log, argv, utils, emailOnError} = require('../../botbase'); const OresUtils = require('../OresUtils'); process.chdir(__dirname); @@ -171,7 +171,7 @@ process.chdir(__dirname); if (isStarred(topic)) { pagetitle = meta(topic); } - var table = new mwn.table({ sortable: true, multiline: true }); + var table = new Mwn.table({ sortable: true, multiline: true }); table.addHeaders([ `scope="col" style="width: 5em;" | AfD date`, `scope="col" style="width: 19em;" | Article`, diff --git a/reports/afd-sorting/afd-sorting.js b/reports/afd-sorting/afd-sorting.js index e7e0f31..426fb47 100644 --- a/reports/afd-sorting/afd-sorting.js +++ b/reports/afd-sorting/afd-sorting.js @@ -1,4 +1,4 @@ -const {mwn, bot, log, argv, utils, emailOnError} = require('../../botbase'); +const {Mwn, bot, log, argv, utils, emailOnError} = require('../../botbase'); const OresUtils = require('../OresUtils'); const {normaliseShortdesc, populateWikidataShortdescs, escapeForTableCell, saveWithBlacklistHandling } = require('../commons'); @@ -169,7 +169,7 @@ process.chdir(__dirname); if (isStarred(topic)) { pagetitle = meta(topic); } - var table = new mwn.table({ + var table = new Mwn.table({ style: 'overflow-wrap: anywhere' }); table.addHeaders([ diff --git a/reports/commons.js b/reports/commons.js index b75a400..f30fe58 100644 --- a/reports/commons.js +++ b/reports/commons.js @@ -1,4 +1,4 @@ -const {bot, mwn, log, emailOnError} = require('../botbase'); +const {bot, Mwn, log, emailOnError} = require('../botbase'); const OresUtils = require('./OresUtils'); /** @@ -7,7 +7,7 @@ const OresUtils = require('./OresUtils'); */ async function populateWikidataShortdescs(tableInfo) { /* GET WIKIDATA SHORTDESCS */ - const wdbot = new mwn({ + const wdbot = new Mwn({ ...bot.options, apiUrl: 'https://www.wikidata.org/w/api.php' }); diff --git a/reports/declined-afcs.js b/reports/declined-afcs.js index 00eb223..f05bf21 100644 --- a/reports/declined-afcs.js +++ b/reports/declined-afcs.js @@ -1,4 +1,4 @@ -const {argv, bot, log, TextExtractor, emailOnError, mwn, utils} = require('../botbase'); +const {argv, bot, log, TextExtractor, emailOnError, Mwn, utils} = require('../botbase'); const {AfcDraftSize, populateWikidataShortdescs, populateOresQualityRatings, comparators, preprocessDraftForExtract, saveWithBlacklistHandling} = require('./commons'); const {enwikidb} = require("../db"); @@ -104,7 +104,7 @@ await populateOresQualityRatings(tableInfo); // Wikidata short descriptions await populateWikidataShortdescs(tableInfo); -let table = new mwn.table({ +let table = new Mwn.table({ style: 'overflow-wrap: anywhere' }); table.addHeaders([ diff --git a/reports/draftify-watch.js b/reports/draftify-watch.js index 5e5b84e..a244952 100644 --- a/reports/draftify-watch.js +++ b/reports/draftify-watch.js @@ -1,4 +1,4 @@ -const {bot, mwn, log, utils, emailOnError, TextExtractor} = require('../botbase'); +const {bot, Mwn, log, utils, emailOnError, TextExtractor} = require('../botbase'); const {formatSummary, saveWithBlacklistHandling} = require('./commons'); (async () => { @@ -117,10 +117,10 @@ const {formatSummary, saveWithBlacklistHandling} = require('./commons'); { label: `Move summary` }, ]; - var maintable = new mwn.table(); + var maintable = new Mwn.table(); maintable.addHeaders(tableHeaders); - let footertable = new mwn.table(); + let footertable = new Mwn.table(); footertable.addHeaders(tableHeaders); for (let [page, data] of Object.entries(tableInfo)) { diff --git a/reports/g13-1week.ts b/reports/g13-1week.ts index afd513d..946cbf8 100644 --- a/reports/g13-1week.ts +++ b/reports/g13-1week.ts @@ -1,4 +1,4 @@ -import { argv, bot, emailOnError, log, mwn, TextExtractor } from "../botbase"; +import { argv, bot, emailOnError, log, Mwn, TextExtractor } from "../botbase"; import { ApiRevision, MwnDate} from "../../mwn"; import { AfcDraftSize, @@ -125,7 +125,7 @@ async function runForDate(date: MwnDate) { // Wikidata short descriptions await populateWikidataShortdescs(tableInfo); - let table = new mwn.table({ + let table = new Mwn.table({ style: 'overflow-wrap: anywhere' }); table.addHeaders([ diff --git a/reports/g13-eligible.js b/reports/g13-eligible.js index 4eb7a01..915434f 100644 --- a/reports/g13-eligible.js +++ b/reports/g13-eligible.js @@ -1,4 +1,4 @@ -const {fs, bot, log, TextExtractor, enwikidb, emailOnError, mwn, utils, argv} = require('../botbase'); +const {fs, bot, log, TextExtractor, enwikidb, emailOnError, Mwn, utils, argv} = require('../botbase'); const {AfcDraftSize, populateWikidataShortdescs, populateOresQualityRatings, comparators, preprocessDraftForExtract, saveWithBlacklistHandling} = require('./commons'); (async function() { @@ -121,7 +121,7 @@ await populateOresQualityRatings(tableInfo); // Wikidata short descriptions await populateWikidataShortdescs(tableInfo); -let table = new mwn.table({ +let table = new Mwn.table({ style: 'overflow-wrap: anywhere' }); table.addHeaders([ diff --git a/reports/g13-watch/g13-watch.ts b/reports/g13-watch/g13-watch.ts index 4cd81b0..563ac7e 100644 --- a/reports/g13-watch/g13-watch.ts +++ b/reports/g13-watch/g13-watch.ts @@ -1,4 +1,4 @@ -import {argv, bot, emailOnError, enwikidb, log, mwn} from "../../botbase"; +import {argv, bot, emailOnError, enwikidb, log, Mwn} from "../../botbase"; import {toolsdb, TOOLS_DB_HOST, ENWIKI_DB_HOST} from "../../db"; import {arrayChunk, createLocalSSHTunnel, closeTunnels} from "../../utils"; import TextExtractor from "../../TextExtractor"; @@ -236,7 +236,7 @@ import * as OresUtils from '../OresUtils'; g13db.end(); log(`[i] ${numDeletions} G13 deletions overall`); - let table = new mwn.table(); + let table = new Mwn.table(); table.addHeaders([ {label: 'Draft', style: 'width: 15em'}, {label: 'Excerpt' }, diff --git a/reports/g13-watch/save-report.ts b/reports/g13-watch/save-report.ts index cdf9a17..60d6804 100644 --- a/reports/g13-watch/save-report.ts +++ b/reports/g13-watch/save-report.ts @@ -3,7 +3,7 @@ // This report relies on ToolsDB g13watch_p database maintained using // eventstream-watch.ts -import { bot, emailOnError, log, mwn } from "../../botbase"; +import { bot, emailOnError, log, Mwn } from "../../botbase"; import { toolsdb, TOOLS_DB_HOST } from "../../db"; import { createLocalSSHTunnel } from "../../utils"; const { saveWithBlacklistHandling } = require('../commons'); @@ -18,7 +18,7 @@ const { saveWithBlacklistHandling } = require('../commons'); const db = new toolsdb('g13watch_p'); log('[S] Connected to the g13 database.'); - let table = new mwn.table(); + let table = new Mwn.table(); table.addHeaders([ {label: 'Date', style: 'width: 5em'}, {label: 'Draft', style: 'width: 18em'}, diff --git a/reports/gan-sorting.js b/reports/gan-sorting.js index d361c09..f3f693d 100644 --- a/reports/gan-sorting.js +++ b/reports/gan-sorting.js @@ -1,4 +1,4 @@ -const {mwn, bot, log, argv, TextExtractor, emailOnError} = require('../botbase'); +const {Mwn, bot, log, argv, TextExtractor, emailOnError} = require('../botbase'); const OresUtils = require('./OresUtils'); const {populateWikidataShortdescs, normaliseShortdesc} = require('./commons'); @@ -182,7 +182,7 @@ const {populateWikidataShortdescs, normaliseShortdesc} = require('./commons'); if (isStarred(topic)) { pagetitle = meta(topic); } - let table = new mwn.table(); + let table = new Mwn.table(); table.addHeaders([ {label: 'Date', class: 'date-header'}, {label: 'Article', class: 'article-header'}, @@ -217,7 +217,7 @@ const {populateWikidataShortdescs, normaliseShortdesc} = require('./commons'); }; let makeMainPage = function () { - let content = mwn.template('/header', { + let content = Mwn.template('/header', { count: Object.keys(revidsTitles).length, countold: counts.old, countrecent: counts.recent, diff --git a/reports/grid-afd-prod.js b/reports/grid-afd-prod.js index 3df5f22..550f42c 100644 --- a/reports/grid-afd-prod.js +++ b/reports/grid-afd-prod.js @@ -1,4 +1,4 @@ -const {mwn, bot, TextExtractor, emailOnError} = require('../botbase'); +const {Mwn, bot, TextExtractor, emailOnError} = require('../botbase'); const {populateWikidataShortdescs, normaliseShortdesc, saveWithBlacklistHandling} = require('./commons'); const months = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; @@ -92,7 +92,7 @@ function parseArticleForPROD(pagetext) { await populateWikidataShortdescs(prodtable); var fnMakeTableAfD = function(afdtable) { - var table = new mwn.table({ sortable: true }); + var table = new Mwn.table({ sortable: true }); table.addHeaders([ 'scope="col" style="width: 5em" | Date', 'scope="col" style="width: 18em" | Article', @@ -110,7 +110,7 @@ function parseArticleForPROD(pagetext) { TextExtractor.finalSanitise(table.getText()); }; var fnMakeTablePROD = function(prodtable) { - var table = new mwn.table({ sortable: true }); + var table = new Mwn.table({ sortable: true }); table.addHeaders([ 'scope="col" style="width: 5em" | Date', 'scope="col" style="width: 18em" | Article', diff --git a/reports/most-imported-scripts/most-imported-scripts.js b/reports/most-imported-scripts/most-imported-scripts.js index c9c5c23..227b764 100644 --- a/reports/most-imported-scripts/most-imported-scripts.js +++ b/reports/most-imported-scripts/most-imported-scripts.js @@ -1,4 +1,4 @@ -const {fs, mwn, bot, utils, log, argv, emailOnError} = require('../../botbase'); +const {fs, Mwn, bot, utils, log, argv, emailOnError} = require('../../botbase'); process.chdir(__dirname); @@ -132,7 +132,7 @@ process.chdir(__dirname); // Create wikitable: - var wikitable = new mwn.table({ sortable: true, style: 'text-align: center' }); + var wikitable = new Mwn.table({ sortable: true, style: 'text-align: center' }); wikitable.addHeaders([ 'Position', 'Script', diff --git a/reports/npp-sorting/npp-sorting.js b/reports/npp-sorting/npp-sorting.js index 70978f9..d4525fa 100644 --- a/reports/npp-sorting/npp-sorting.js +++ b/reports/npp-sorting/npp-sorting.js @@ -1,4 +1,4 @@ -const {log, argv, TextExtractor, mwn, bot, enwikidb, utils, emailOnError} = require('../../botbase'); +const {log, argv, TextExtractor, Mwn, bot, enwikidb, utils, emailOnError} = require('../../botbase'); const OresUtils = require('../OresUtils'); const {populateWikidataShortdescs, normaliseShortdesc} = require('../commons'); const {createLocalSSHTunnel, closeTunnels} = require("../../utils"); @@ -268,7 +268,7 @@ ${replagMessage} editorString = `[[Special:Contribs/${tabledata.creator}|${tabledata.creator}]] (${tabledata.creatorEdits})`; } else { // lowercase IPv6 address and split to 2 lines to reduce column width - if (mwn.util.isIPv6Address(tabledata.creator)) { + if (Mwn.util.isIPv6Address(tabledata.creator)) { var ip = tabledata.creator.toLowerCase(); var idx = Math.round(ip.length / 2); ip = ip.slice(0, idx) + '
' + ip.slice(idx); diff --git a/reports/peer-review.js b/reports/peer-review.js index 22c890b..cc73888 100644 --- a/reports/peer-review.js +++ b/reports/peer-review.js @@ -1,4 +1,4 @@ -const {bot, mwn, log, emailOnError, TextExtractor} = require('../botbase'); +const {bot, Mwn, log, emailOnError, TextExtractor} = require('../botbase'); const {populateWikidataShortdescs} = require('./commons'); (async function() { @@ -79,7 +79,7 @@ await bot.batchOperation(articles, article => { log(`[S] got histories`); -let table = new mwn.table(); +let table = new Mwn.table(); table.addHeaders([ {label: 'Date', class: 'date-header'}, {label: 'Article', class: 'article-header'}, diff --git a/reports/pending-afc.ts b/reports/pending-afc.ts index f0fdc46..28d4d4a 100644 --- a/reports/pending-afc.ts +++ b/reports/pending-afc.ts @@ -1,4 +1,4 @@ -import { argv, bot, emailOnError, enwikidb, log, mwn, TextExtractor } from "../botbase"; +import { argv, bot, emailOnError, enwikidb, log, Mwn, TextExtractor } from "../botbase"; import { AfcDraftSize, comparators, @@ -125,7 +125,7 @@ import { NS_DRAFT } from "../namespaces"; // Wikidata short descriptions await populateWikidataShortdescs(tableInfo); - let table = new mwn.table({ + let table = new Mwn.table({ style: 'overflow-wrap: anywhere' }); table.addHeaders([ diff --git a/reports/prod-sorting/prod-sorting.js b/reports/prod-sorting/prod-sorting.js index 791c2c5..13f18a1 100644 --- a/reports/prod-sorting/prod-sorting.js +++ b/reports/prod-sorting/prod-sorting.js @@ -1,4 +1,4 @@ -const {bot, TextExtractor, mwn, log, argv, utils, emailOnError} = require('../../botbase'); +const {bot, TextExtractor, Mwn, log, argv, utils, emailOnError} = require('../../botbase'); const OresUtils = require('../OresUtils'); const {populateWikidataShortdescs, normaliseShortdesc, saveWithBlacklistHandling} = require('../commons'); @@ -121,7 +121,7 @@ process.chdir(__dirname); if (isStarred(topic)) { pagetitle = meta(topic); } - var table = new mwn.table({ style: 'overflow-wrap: anywhere' }); + var table = new Mwn.table({ style: 'overflow-wrap: anywhere' }); table.addHeaders(lite ? [ // exlcude excerpt in lite mode `scope="col" style="width: 7em;" | PROD date`, diff --git a/reports/prod-watch.js b/reports/prod-watch.js index 97a09c9..7860273 100644 --- a/reports/prod-watch.js +++ b/reports/prod-watch.js @@ -1,4 +1,4 @@ -const {bot, log, mwn, emailOnError} = require('../botbase'); +const {bot, log, Mwn, emailOnError} = require('../botbase'); const {formatSummary, saveWithBlacklistHandling} = require('./commons'); (async function() { @@ -87,7 +87,7 @@ const {formatSummary, saveWithBlacklistHandling} = require('./commons'); } else { // redirect, check if this edit is a page move let moveCommentRgx = new RegExp( - `^${mwn.util.escapeRegExp(rev.user)} moved page \\[\\[${mwn.util.escapeRegExp(page)}\\]\\] to \\[\\[(.*?)\\]\\]` + `^${Mwn.util.escapeRegExp(rev.user)} moved page \\[\\[${Mwn.util.escapeRegExp(page)}\\]\\] to \\[\\[(.*?)\\]\\]` ); let match = rev.comment.match(moveCommentRgx); if (match) { @@ -141,7 +141,7 @@ const {formatSummary, saveWithBlacklistHandling} = require('./commons'); return bot.search('prefix:Wikipedia:Articles for deletion/' + page, 5, '', { srsort: 'create_timestamp_desc' // get most recent afd first if there are multiple }).then(afds => { - var sanityRgx = new RegExp('Wikipedia:Articles for deletion/' + mwn.util.escapeRegExp(page) + '( \\((2nd|3rd|\\dth) nomination\\))?$'); + var sanityRgx = new RegExp('Wikipedia:Articles for deletion/' + Mwn.util.escapeRegExp(page) + '( \\((2nd|3rd|\\dth) nomination\\))?$'); for (let afd of afds) { if (!sanityRgx.test(afd.title)) { continue; @@ -261,7 +261,7 @@ const {formatSummary, saveWithBlacklistHandling} = require('./commons'); var makeTable = function(header3, set) { - var table = new mwn.table(); + var table = new Mwn.table(); table.addHeaders([ { style: 'width: 15em;', label: `Article`}, { style: 'width: 25em;', label: `Excerpt`}, diff --git a/reports/redirectify-watch.js b/reports/redirectify-watch.js index fe8f710..0d951ec 100644 --- a/reports/redirectify-watch.js +++ b/reports/redirectify-watch.js @@ -1,4 +1,4 @@ -const {mwn, bot, log, emailOnError, TextExtractor} = require('../botbase'); +const {Mwn, bot, log, emailOnError, TextExtractor} = require('../botbase'); const {formatSummary, saveWithBlacklistHandling} = require('./commons'); (async function() { @@ -33,7 +33,7 @@ let json = await bot.request({ const actions = json.query.recentchanges; log(`[S] Fetched data from the API - ${actions.length} pages`); -let table = new mwn.table({ +let table = new Mwn.table({ // overflow-wrap: anywhere avoids a column from being widened due to one user // using a very large "word" (eg. an external link or a wikilink with underscores) // in the summary diff --git a/reports/unreferenced-blps.js b/reports/unreferenced-blps.js index a59bfc6..97586ba 100644 --- a/reports/unreferenced-blps.js +++ b/reports/unreferenced-blps.js @@ -1,6 +1,6 @@ -const {bot, mwn, log, fs, TextExtractor} = require('../botbase'); +const {bot, Mwn, log, fs, TextExtractor} = require('../botbase'); -const wd = new mwn({ +const wd = new Mwn({ ...bot.options, apiUrl: 'https://www.wikidata.org/w/api.php', hasApiHighLimit: false @@ -85,9 +85,9 @@ for await (let json of bot.continuedQueryGen({ log(`[S] got data from the APIs`); let tables = { - men: new mwn.table(), - women: new mwn.table(), - unknown: new mwn.table() + men: new Mwn.table(), + women: new Mwn.table(), + unknown: new Mwn.table() }; let headers = [ {label: 'Article', style: 'width: 17em'}, diff --git a/webservice/app.ts b/webservice/app.ts index 40324c3..b38f514 100644 --- a/webservice/app.ts +++ b/webservice/app.ts @@ -8,7 +8,7 @@ import * as cors from 'cors'; // All paths to SDZeroBot files must be via ../../SDZeroBot rather than via ../ // The latter will work locally but not when inside toolforge www/js directory! -import { bot, mwn } from "../../SDZeroBot/botbase"; +import { bot, Mwn } from "../../SDZeroBot/botbase"; import { humanDate } from "../../mwn/build/log"; import { createLocalSSHTunnel } from "../../SDZeroBot/utils"; import { ENWIKI_DB_HOST, TOOLS_DB_HOST } from "../../SDZeroBot/db"; @@ -21,7 +21,7 @@ const app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'hbs'); hbs.registerHelper('wikilink', (pageName, displayName) => { - return `${typeof displayName === 'string' ? displayName : pageName}`; + return `${typeof displayName === 'string' ? displayName : pageName}`; }); morgan.token('date', () => humanDate()); diff --git a/webservice/routes/gitsync.ts b/webservice/routes/gitsync.ts index 6bdd25a..9a1f648 100644 --- a/webservice/routes/gitsync.ts +++ b/webservice/routes/gitsync.ts @@ -1,6 +1,6 @@ import * as express from "express"; import * as multer from 'multer'; -import {mwn} from "../../../mwn"; +import {Mwn} from "../../../mwn"; const router = express.Router(); const upload = multer(); @@ -9,7 +9,7 @@ const upload = multer(); router.post('/savepage', upload.none(), async (req, res) => { try { - const client = await mwn.init({ + const client = await Mwn.init({ apiUrl: req.body.apiUrl, username: req.body.username, password: req.body.password,