koishi-plugin-rryth-test
Version:
人人有图画测试服
60 lines (58 loc) • 3.06 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name2 in all)
__defProp(target, name2, { get: all[name2], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.tsx
var src_exports = {};
__export(src_exports, {
Config: () => Config,
apply: () => apply,
name: () => name
});
module.exports = __toCommonJS(src_exports);
var import_koishi = require("koishi");
var import_jsx_runtime = require("@satorijs/element/jsx-runtime");
var name = "rryth-test";
function apply(ctx, config) {
const resolution = /* @__PURE__ */ __name((resolution2) => +resolution2 & ~63, "resolution");
ctx.command("rryth-test <prompt:text>", "人人有图画测试服 v0.0.8").usage("这里会不定期更新一些有意思的功能,也随时会关闭服务\n这次的是 FLUX,它好像啥风格都能画。rt 为原版、rta 为动漫风格。").alias("rt", { options: { width: 768, height: 512 } }).alias("rta", { options: { width: 512, height: 768 }, args: ["anime"] }).option("iterations", "-i <iterations:number> 多来几下", { authority: 2 }).action(async ({ session, options }, ...prompts) => {
const prompt = prompts.join(", ");
if (!prompt)
return session.execute("help rt");
const request = { prompt, ...options };
const rr = /* @__PURE__ */ __name(async (request2) => {
const { images: images2 } = await ctx.http.post("https://rr.elchapo.cn", request2, { headers: { "api": "FLUX.0" } }).catch((e) => ctx.logger.error(e));
return images2.map((image) => {
return config.censor ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("censor", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: "data:image/png;base64," + image }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: "data:image/png;base64," + image });
});
}, "rr");
const images = await rr(request);
session.send(images);
});
}
__name(apply, "apply");
var Config = import_koishi.Schema.object({
censor: import_koishi.Schema.boolean().description("是否启用图像审查。").default(false),
batch: import_koishi.Schema.number().description("默认出图数量。").default(1).max(4).min(1).role("slider").disabled().hidden()
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Config,
apply,
name
});
//# sourceMappingURL=index.js.map