UNPKG

kotori-plugin-penis

Version:

查看今日牛牛的长度和排行和寸止

243 lines (242 loc) 11.7 kB
/** * @Package kotori-plugin-penis * @Version 1.3.1 * @Author Himeno <me@hotaru.icu> * @Copyright 2024-2025 Hotaru. All rights reserved. * @License GPL-3.0 * @Link https://github.com/kotorijs/kotori * @Date 2026/3/29 14:23:44 */ "use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], 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); var index_exports = {}; __export(index_exports, { config: () => config, inject: () => inject, lang: () => lang, main: () => main }); module.exports = __toCommonJS(index_exports); var import_kotori_bot = require("kotori-bot"); const lang = [__dirname, "../locales"]; const inject = ["file", "server"]; const config = import_kotori_bot.Tsu.Object({ max: import_kotori_bot.Tsu.Number().default(30).describe("The maximum length of the dick"), min: import_kotori_bot.Tsu.Number().default(-30).describe("The minimum length of the dick"), joke: import_kotori_bot.Tsu.Number().default(10).describe("Send a joke when the length is less than value"), avgMinNum: import_kotori_bot.Tsu.Number().default(5).describe("The minimum at avg rank"), probability: import_kotori_bot.Tsu.Number().default(0.45).describe("\u4E0D\u6000\u5B55\u7684\u6982\u7387 (0-1)"), cutProbability: import_kotori_bot.Tsu.Number().default(0.4).describe("\u5BF8\u6B62\u5931\u8D25\u7684\u6982\u7387 (0-1)"), maxCount: import_kotori_bot.Tsu.Number().default(4).describe("\u5355\u4E2A\u7528\u6237\u6BCF\u65E5\u6700\u5927\u793E\u6B21\u6570"), maxCount2: import_kotori_bot.Tsu.Number().default(2).describe("\u5355\u4E2A\u7528\u6237\u6BCF\u65E5\u6700\u5927\u88AB\u793E\u6B21\u6570") }); function main(ctx, config2) { const getNewLength = () => config2.min + Math.floor(Math.random() * (config2.max - config2.min + 1)); const getTodayPath = () => `${(/* @__PURE__ */ new Date()).getFullYear()}-${(/* @__PURE__ */ new Date()).getMonth() + 1}-${(/* @__PURE__ */ new Date()).getDay()}.json`; const loadTodayData = () => ctx.file.load(getTodayPath(), "json", {}); const saveTodayData = (data) => ctx.file.save(getTodayPath(), data); const loadStatData = () => ctx.file.load("stat.json", "json", {}); const saveStatData = (data) => ctx.file.save("stat.json", data); const DATA_FILE = "cum_you_data.json"; const loadData = () => ctx.file.load(DATA_FILE, "json", {}); const saveData = (data) => ctx.file.save(DATA_FILE, data); const getTodayStart = () => new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0)).getTime(); ctx.command("dick - \u83B7\u53D6\u4ECA\u65E5\u725B\u725B\u957F\u5EA6").shortcut("\u4ECA\u65E5\u957F\u5EA6").action((_, session) => { const id = `${session.api.adapter.identity}${session.userId}`; const today = loadTodayData(); const todayLength = typeof today[id] === "number" ? today[id] : getNewLength(); const params = [import_kotori_bot.Messages.mention(session.userId), todayLength]; if (todayLength <= 0) session.quick(["newnew.msg.today_length.info.2", params]); else if (todayLength > 0 && todayLength <= config2.joke) session.quick(["newnew.msg.today_length.info.1", params]); else session.quick(["newnew.msg.today_length.info.0", params]); if (typeof today[id] === "number") return; today[id] = todayLength; saveTodayData(today); const stat = loadStatData(); const person = stat[id]; if (Array.isArray(person)) { if (todayLength <= person[0]) person[0] = todayLength; if (todayLength >= person[1]) person[1] = todayLength; person[2] += 1; person[3] += todayLength; } else { stat[id] = [todayLength, todayLength, 1, todayLength]; } saveStatData(stat); }); ctx.command("mydick - \u83B7\u53D6\u6211\u7684\u725B\u725B\u957F\u5EA6").shortcut("\u6211\u7684\u957F\u5EA6").action((_, session) => { const stat = loadStatData(); const person = stat[`${session.api.adapter.identity}${session.userId}`]; const params = [import_kotori_bot.Messages.mention(session.userId)]; if (!person || person.length <= 0) return session.format("newnew.msg.my_length.fail", params); return session.format("newnew.msg.my_length", [ params[0], person[1], person[0], person[2], person[3], (person[3] / person[2]).toFixed(2) ]); }); ctx.command("avgdick - \u67E5\u770B\u725B\u725B\u957F\u5EA6\u5E73\u5747\u6392\u884C").shortcut("\u5E73\u5747\u6392\u884C").action((_, session) => { const stat = loadStatData(); const statOrigin = loadStatData(); if (Object.keys(stat).length <= 0) return "newnew.msg.avg_ranking.fail"; for (const key in stat) { const item = stat[key]; item[3] /= item[2]; } const entries = Object.entries(stat).filter((val) => val[0].startsWith(session.api.adapter.identity)); entries.sort((a, b) => b[1][3] - a[1][3]); let list = ""; let num = 1; for (const entry of entries) { if (num > 20) continue; const nums = entry[1][2]; if (nums < config2.avgMinNum) continue; list += session.format("newnew.msg.avg_ranking.list", [ num, entry[0].slice(session.api.adapter.identity.length), entry[1][3].toFixed(2), nums, statOrigin[entry[0]][3] ]); num += 1; } return session.format("newnew.msg.avg_ranking", [list]); }); ctx.command("daydick - \u67E5\u770B\u725B\u725B\u957F\u5EA6\u4ECA\u65E5\u6392\u884C").shortcut("\u4ECA\u65E5\u6392\u884C").action((_, session) => { const today = loadTodayData(); if (today.length <= 0) return "newnew.msg.today_ranking.fail"; const entries = Object.entries(today).filter((val) => val[0].startsWith(session.api.adapter.identity)); entries.sort((a, b) => b[1] - a[1]); let list = ""; let num = 1; for (const entry of entries) { if (num > 20) continue; list += session.format("newnew.msg.today_ranking.list", [ num, entry[0].slice(session.api.adapter.identity.length), entry[1] ]); num += 1; } return session.format("newnew.msg.today_ranking", [list]); }); ctx.command("cum [user:string] - \u793E\u4FDD\u4F60\u7684\u7FA4\u53CB").shortcut("\u793E\u4FDD").option("C", "cut:boolean \u5BF8\u6B62\u6A21\u5F0F").action(async ({ args, options: { cut } }, session) => { const data = loadData(); const todayStart = getTodayStart(); const senderId = `${session.api.adapter.identity}${session.userId}`; const senderRecord = data[senderId] || { given: 0, received: 0, lastTime: 0 }; if (senderRecord.lastTime < todayStart) { senderRecord.given = 0; senderRecord.received = 0; senderRecord.lastTime = Date.now(); } if (senderRecord.given >= config2.maxCount) { return session.quick(["\u6742\u9C7C\u6B27\u5C3C\u9171\uFF0C\u4F60\u4ECA\u5929\u5DF2\u7ECF\u793E\u4E86 {0} \u6B21\u4E86\uFF0C\u8EAB\u4F53\u8981\u88AB\u638F\u7A7A\u4E86\u54E6\uFF01\u4F11\u606F\u4E0B\u5427\u3002", [config2.maxCount]]); } const targetId = args[0] ?? session.userId; const targetFullId = `${session.api.adapter.identity}${targetId}`; const targetRecord = data[targetFullId] || { given: 0, received: 0, lastTime: 0 }; if (targetRecord.lastTime < todayStart) { targetRecord.given = 0; targetRecord.received = 0; targetRecord.lastTime = Date.now(); } if (targetRecord.received >= config2.maxCount2) { return session.quick(["\u7FA4\u53CB {0} \u7684\u5C0F\u809A\u809A\u5DF2\u7ECF\u88C5\u4E0D\u4E0B\u4E86\uFF0C\u8BF7\u4E0D\u8981\u518D\u793E\u4E86\uFF01", [import_kotori_bot.Messages.mention(targetId)]]); } const cutFailed = Math.random() < config2.cutProbability; const noPregnancy = Math.random() < config2.probability; const babyTypes = [ "\u4E00\u53EA\u7537\u5A03", "\u4E00\u53EA\u5973\u5A03", "\u4E00\u5BF9\u7537\u5A03\u53CC\u80DE\u80CE", "\u4E00\u5BF9\u5973\u5A03\u53CC\u80DE\u80CE", "\u4E09\u80DE\u80CE\uFF01", "\u4E00\u4E2A\u5927\u80D6\u5C0F\u5B50", "\u4E00\u5BF9\u9F99\u51E4\u53CC\u80DE\u80CE", "\u4E00\u53EA\u5C0F\u5DE7\u5C0F\u5973\u513F" ]; const pickBaby = () => babyTypes[Math.floor(Math.random() * babyTypes.length)]; if (cut) { if (cutFailed) { senderRecord.given++; targetRecord.received++; const babyStr = noPregnancy ? "\u5E86\u5E78\u7684\u662F\u6CA1\u6709\u6000\u5B55" : `\u7FA4\u53CB\u8BDE\u4E0B\u4E86 ${pickBaby()}`; session.quick([`\u4F60\u5728 cum \u7FA4\u53CB {0} \u7684\u8FC7\u7A0B\u4E2D\u4F7F\u7528\u4E86\u5BF8\u6B62\uFF0C\u4F46\u4F60\u6CA1\u5FCD\u4F4F\uFF01${babyStr}`, [import_kotori_bot.Messages.mention(targetId)]]); } else { session.quick(["\u4F60\u5728 cum \u7FA4\u53CB {0} \u7684\u8FC7\u7A0B\u4E2D\u6210\u529F\u5BF8\u6B62\uFF01(\u597D\u8170\u529B\uFF01)", [import_kotori_bot.Messages.mention(targetId)]]); } } else { senderRecord.given++; targetRecord.received++; if (noPregnancy) { session.quick(["\u4F60\u793E\u4FDD\u4E86\u7FA4\u53CB {0}\uFF0C\u4F46\u5979\u5E76\u6CA1\u6709\u6000\u5B55\u2026\u2026", [import_kotori_bot.Messages.mention(targetId)]]); } else { session.quick([`\u4F60\u793E\u4FDD\u4E86\u7FA4\u53CB {0} \u5E76\u8BDE\u4E0B\u4E86 ${pickBaby()}`, [import_kotori_bot.Messages.mention(targetId)]]); } } const now = Date.now(); senderRecord.lastTime = now; targetRecord.lastTime = now; data[senderId] = senderRecord; data[targetFullId] = targetRecord; saveData(data); }); ctx.command("cum-check [user:string] - \u67E5\u770B\u793E\u4FDD\u7EDF\u8BA1").shortcut("\u793E\u4FDD\u67E5\u8BE2").action(({ args }, session) => { const data = loadData(); const targetId = args[0] ?? session.userId; const fullId = `${session.api.adapter.identity}${targetId}`; const record = data[fullId]; const todayStart = getTodayStart(); let given = 0; let received = 0; if (record && record.lastTime >= todayStart) { given = record.given; received = record.received; } return session.format( `\u7FA4\u53CB {0} \u4ECA\u65E5\u7EDF\u8BA1\uFF1A \u4E3B\u52A8\u793E\u4E86\uFF1A${given}/${config2.maxCount} \u6B21 \u88AB\u52A8\u53D7\u5B55\uFF1A${received}/${config2.maxCount2} \u6B21`, [import_kotori_bot.Messages.mention(targetId)] ); }); ctx.command("cum-reset [user:string] - \u91CD\u7F6E\u6B21\u6570").shortcut("\u793E\u4FDD\u91CD\u7F6E").access(import_kotori_bot.UserAccess.MANGER).action(({ args }, session) => { const data = loadData(); const targetId = args[0] ?? session.userId; const fullId = `${session.api.adapter.identity}${targetId}`; data[fullId] = { given: 0, received: 0, lastTime: Date.now() }; saveData(data); return session.format("\u5DF2\u624B\u52A8\u4FEE\u6B63\uFF1A\u7FA4\u53CB {0} \u7684\u88AB\u793E\u6B21\u6570\u5DF2\u91CD\u7F6E", [import_kotori_bot.Messages.mention(targetId)]); }); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { config, inject, lang, main });