UNPKG

koishi-plugin-censure

Version:

Generating copy for condemning others

65 lines (63 loc) 2.56 kB
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.ts var src_exports = {}; __export(src_exports, { Config: () => Config, apply: () => apply, inject: () => inject, name: () => name }); module.exports = __toCommonJS(src_exports); var import_koishi = require("koishi"); var name = "censure"; var Config = import_koishi.Schema.object({ censor: import_koishi.Schema.boolean().description("是否启用输出内容审核。").default(false) }); var inject = { optional: ["censor"] }; function apply(ctx, cfg) { ctx.command("censure <target> <event>", "生成谴责文案").alias("谴责").action(async ({ source }, target, event) => { if (isEmpty(target)) return "你没有输入目标。"; if (isEmpty(event)) return "你没有输入事件。"; if (source.includes("&lt;") && source.includes("&gt;")) return "你没有好好说话。"; if (target.includes("。") || event.includes("。")) return "你没有好好说话。"; const a = target, b = event; const content = `我方对${b}表示强烈谴责。${b}${a}的蓄意行为,这种行为侵犯了我方的正当权益。我方要求${a}立即停止${b},并采取措施纠正错误。我方将继续密切关注此事的进展,并采取一切必要措施,以维护我方的正当权益。`; if (cfg.censor) { if (!ctx.censor) throw new Error("missing censor service"); return `<censor>${content}</censor>`; } else { return content; } }); } __name(apply, "apply"); function isEmpty(value) { return value === void 0 || value === ""; } __name(isEmpty, "isEmpty"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Config, apply, inject, name });