mwn
Version:
JavaScript & TypeScript MediaWiki bot framework for Node.js
48 lines (47 loc) • 1.75 kB
TypeScript
import type { Mwn } from './bot';
import type { MwnTitle } from './title';
import type { MwnPage } from './page';
import { ApiQueryBacklinkspropParams } from 'types-mediawiki-api';
export interface MwnFileStatic {
/**
* @constructor
* @param {string|MwnTitle} name - name of the file
*/
new (title: MwnTitle | string): MwnFile;
}
export interface MwnFile extends MwnPage {
/**
* Get the name of the file without extension or namespace prefix.
*
* @return {string} File name without file extension, in the canonical form with
* underscores instead of spaces. For example, the title "File:Example_image.svg"
* will be returned as "Example_image".
*/
getName(): string;
/**
* Get the name of the file without extension or namespace prefix.
*
* @return {string} File name without file extension, formatted with spaces instead
* of underscores. For example, the title "File:Example_image.svg" will be returned
* as "Example image".
*/
getNameText(): string;
/**
* Get file usages
* @param {Object} options - additional API options
* @returns {Promise<Object[]>} - resolved with array of { pageid: 32434,
* ns: 0, title: 'Main Page', redirect: false } like objects.
*/
usages(options?: ApiQueryBacklinkspropParams): Promise<{
pageid: number;
title: string;
redirect: boolean;
}[]>;
/**
* Download an image from the wiki to the local file system
* @param localname - local path (with file name) to download to,
* defaults to current directory with same file name as on the wiki.
*/
download(localname: string): void;
}
export default function (bot: Mwn): MwnFileStatic;