@wahaha216/koishi-plugin-jmcomic
Version:
下载JM本子,无需python。支持pdf、zip加密。
80 lines (79 loc) • 2.98 kB
TypeScript
import { Config } from "..";
import { HTTP, Logger } from "koishi";
import { IJMResponse } from "../types/JMClient";
import { Encoding } from "crypto";
/**
* 文件是否存在
* @param path 文件路径
* @returns 文件是否存在
*/
export declare function fileExistsAsync(path: string): boolean;
/**
* 获取文件大小
* @param path 文件路径
* @returns 文件大小
*/
export declare function fileSizeAsync(path: string): number;
/**
* 文件名合法化
* @param fileName 文件名
* @returns 合法化后的文件名
*/
export declare function sanitizeFileName(fileName: string): string;
/**
* 从github获取最新的JM域名
* @returns 域名列表
*/
export declare function getDomainFromGithub(http: HTTP): Promise<any[]>;
/**
* 限制Promise并发
* @param promises Promise方法列表
* @param limit 限制数量
* @returns Promise结果
*/
export declare function limitPromiseAll<T>(promises: (() => Promise<T>)[], limit: number): Promise<T[]>;
/**
* 重试请求,直到遇到特定错误或者次数耗尽
* @param url 请求地址
* @param method 请求方法
* @param config 请求配置
* @param retryIndex 尝试次数
* @returns 请求结果
*/
export declare function requestWithRetry<T = IJMResponse>(url: string, method: "GET" | "POST", config: HTTP.RequestConfig, http: HTTP, pluginsConfig: Config, logger: Logger, retryIndex?: number): Promise<T>;
/**
* 依次使用定义的地址尝试进行请求,遇到特定错误尝试切换下一个
* @param url 请求地址
* @param method 请求方法
* @param config 请求配置
* @param urlIndex 地址下标,默认从0开始尝试
* @returns 请求结果
*/
export declare function requestWithUrlSwitch<T = IJMResponse>(url: string, method: "GET" | "POST", config: HTTP.RequestConfig, http: HTTP, pluginsConfig: Config, logger: Logger, type?: "IMAGE" | "CLIENT", urlIndex?: number, isUpdate?: boolean): Promise<T>;
/**
* 获取文件名和扩展名
* @param filePath 文件路径
* @returns 文件名、扩展名和路径组成的对象 { fileName, ext, dir }
*/
export declare function getFileInfo(filePath: string): {
fileName: string;
ext: string;
dir: string;
};
/**
* 删除路径下 days 之前的文件夹
* @param path 路径
* @param days 天数
*/
export declare function deleteFewDaysAgoFolders(path: string, days: number): Promise<void>;
export declare function formatFileName(originName: string, name: string, id: string, index?: number): string;
export declare function md5Hex(key: string, inputEncoding?: Encoding): string;
/**
* 解密加密字符串
* @param timestamp 请求时传递的时间戳
* @param base64 待解密的字符串
* @param secret
* @returns 解密结果,JSON
*/
export declare function decodeBase64<T = Record<string, unknown>>(base64: string, timestamp: number | string, secret?: string): T;
export declare function updateApiDomain(http: HTTP, config: Config, logger: Logger): Promise<boolean>;