UNPKG

koishi-plugin-booru

Version:
69 lines (68 loc) 2.2 kB
import { Context, Element, HTTP, Schema } from 'koishi'; export declare abstract class ImageSource<Config extends ImageSource.Config = ImageSource.Config> { ctx: Context; config: Config; static inject: string[] | Partial<Record<'required' | 'optional', string[]>>; languages: string[]; source: string; http: HTTP; constructor(ctx: Context, config: Config); /** * split query into tags, default implementation is comma-separated. * * e.g. `tag1, wordy tag2, UPPER CASED tag3` => `['tag1', 'wordy_tag2', 'upper_cased_tag3']` */ tokenize(query: string): string[]; abstract get(query: ImageSource.Query): Promise<ImageSource.Result[]>; } export declare namespace ImageSource { interface Config { label: string; weight: number; proxyAgent: string; } function createSchema(o: { label: string; }): Schema<Schemastery.ObjectS<{ label: Schema<string, string>; weight: Schema<number, number>; }> | Schemastery.ObjectS<{ proxyAgent: Schema<string, string>; }>, { label: string; weight: number; } & import("cosmokit").Dict & { proxyAgent: string; }>; const Config: Schema<Config>; interface Query { tags: string[]; /** raw query */ raw: string; count: number; } type NsfwType = 'furry' | 'guro' | 'shota' | 'bl'; enum PreferSize { Original = "original", Large = "large", Medium = "medium", Small = "small", Thumbnail = "thumbnail" } interface Result { /** @deprecated Use `.urls.*` instead */ url?: string; urls: Partial<Record<Exclude<PreferSize, 'original'>, string>> & { original: string; }; pageUrl?: string; author?: string; authorUrl?: string; title?: string; desc?: string | Element; tags?: string[]; nsfw?: boolean | NsfwType; } } export declare const preferSizes: readonly ["thumbnail", "large", "medium", "small", "original"]; export declare const sizeNameToFixedWidth: Partial<Record<(typeof preferSizes)[number], number>>;