UNPKG

e621-sdk

Version:

从E621抓取帖子。支持搜索、引用、随机。

57 lines (56 loc) 1.9 kB
import { AxiosRequestConfig } from "axios"; import { Post } from "./structs"; import { SearchConfig } from "./structs/config"; import { AccountInfo } from "./structs/auth"; import { ValidIdField } from "./structs/value"; export declare class E621Authenticator { imageUrls: Record<string, string>; useImage: false | string; axiosConfig: AxiosRequestConfig; configureAxios(config: Partial<AxiosRequestConfig>): void; accountInfo: AccountInfo | null; get isAuthorized(): boolean; get authorizationCode(): string | undefined; login(username: string, apikey: string): Promise<void>; delImage(name: string): void; addImage(name: string, url: string, autoUse?: boolean): void; use(name: string | false): void; } export declare class E621 extends E621Authenticator { rateLimiter: RateLimiter | null; log: boolean; constructor(config?: { rateLimiter?: RateLimiter; log?: boolean; }); searchPost(config?: Partial<SearchConfig>): Promise<PostWrapper[]>; fetchPost(id: ValidIdField): Promise<PostWrapper>; randomPost(...tags: string[]): Promise<PostWrapper>; static(md5: string, ext: string, progressCallback?: (event: { loaded: number; total: number; percent: number; }) => void): Promise<ArrayBuffer>; serverStatus(): Promise<{ status: boolean; message: unknown | null; }>; } /** * @description 限制请求速率 */ export declare class RateLimiter { intervalPerRequest: number; lastRequest: number; get time(): number; get rest(): number; get ready(): boolean; start(): boolean; wait(): Promise<number>; } export declare class PostWrapper { data: Post | null; parentClient: E621 | null; constructor(data: Post, client: E621); get formatted(): string | null; }