///
import { Context, Session, Dict } from 'koishi';
import { PicsPluginConfig } from './config';
import { segment, Element } from 'koishi';
import { LifecycleEvents, Renderer } from 'koishi-thirdeye';
import { PicMiddleware, PicResult } from './def';
import { PicSource } from './picsource';
export * from './config';
export * from './middleware';
export * from './picsource';
export * from './def';
declare module 'koishi' {
interface Context {
pics: PicsContainer;
}
}
declare const PicsContainer_base: new (ctx: Context, config: {
commandName?: string;
useAssets?: boolean;
useBase64?: boolean;
httpConfig?: {
headers?: {
[x: string]: any;
};
endpoint?: string;
timeout?: number;
proxyAgent?: string;
};
preferFile?: boolean;
}) => {
ctx: Context;
config: PicsPluginConfig;
};
export default class PicsContainer extends PicsContainer_base implements LifecycleEvents {
private sources;
private picMiddlewares;
private caller;
private logger;
private http;
private _http;
addSource(source: PicSource, targetCtx?: Context): void;
removeSource(source: PicSource): Promise;
private allSources;
middleware(mid: PicMiddleware, targetCtx?: Context): void;
removeMiddlware(mid: PicMiddleware): void;
pickAvailableSources(sourceTags?: string[], includeNonDefault?: boolean): PicSource[];
randomSourceWithWeight(sources?: PicSource[]): PicSource;
private retryWithAnotherSource;
private fetchPicsWithSources;
randomPic(picTags?: string[], sourceTags?: string[]): Promise;
urlToBuffer(url: string): Promise<{
buffer: Buffer;
mime: string;
}>;
bufferToUrl(buffer: Buffer, mime?: string): Promise;
download(url: string): Promise;
resolveUrl(url: string, middlewares?: PicMiddleware[]): Promise;
getSegment(url: string): Promise;
private installDefaultMiddlewares;
onPic(source: string, picTags: string[], notFound: Renderer): Promise;
onQuerySource(sourceTags: string[], list: Renderer): Promise;
onApply(): void;
picsComponent(attrs: Dict, children: Element[], session: Session): Promise;
}