UNPKG

koishi-plugin-memes-api

Version:

表情包制作插件调用 API 版

55 lines (54 loc) 1.94 kB
import { Context, Session, h } from 'koishi'; import { MemeImage, MemeInfo, MemeOptionType } from 'meme-generator-rs-api'; import { Config } from '../config'; import { UserInfoGender } from '../utils/user-info'; export interface ResolvedShortcutInfo { rawMessage: h[]; names?: string[]; texts?: string[]; options?: Record<string, any>; } export interface SessionInternal { inGenerateSubCommand?: boolean; shortcut?: boolean; } declare module 'koishi' { interface Session { memesApi: SessionInternal; } } export interface OptionInfo { names: string[]; argName: string; type: string; description: string; } export type ImageFetchInfo = { src: string; } | { userId: string; }; export interface ResolvedArgs { imageInfos: ImageFetchInfo[]; texts: string[]; names: string[]; } export interface ImagesAndInfos { images: Blob[]; names: string[]; gender: UserInfoGender; } declare module '../index' { interface MemeInternal { resolveArgs(session: Session, args: h[]): Promise<ResolvedArgs>; resolveImagesAndInfos: (session: Session, imageInfos: ImageFetchInfo[], existingNames?: string[]) => Promise<ImagesAndInfos>; checkAndCountToGenerate(session: Session): Promise<h[] | undefined>; uploadImages(images: Blob[]): Promise<string[]>; uploadImagesAndProcess(meme: MemeInfo, uploadInfo: ImagesAndInfos, options?: Record<string, any>): Promise<MemeImage[]>; normalizeOptionType(type: MemeOptionType): string; checkOptions(session: Session, options: Record<string, any>, info: MemeInfo): Promise<h.Fragment | undefined>; uploadImgAndRenderMeme(meme: MemeInfo, texts: string[], uploadInfo: ImagesAndInfos, options: Record<string, any>): Promise<Blob>; reRegisterGenerateCommands: () => Promise<void>; } } export declare function apply(ctx: Context, config: Config): Promise<void>;