UNPKG

kotori-plugin-penis

Version:

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

144 lines (141 loc) 6.06 kB
/** * @Package kotori-plugin-penis * @Version 1.2.3 * @Author Himeno <me@hotaru.icu> * @Copyright 2024 Hotaru. All rights reserved. * @License GPL-3.0 * @Link https://github.com/kotorijs/kotori * @Date 2024/8/8 20:54:12 */ "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 src_exports = {}; __export(src_exports, { config: () => config, inject: () => inject, lang: () => lang, main: () => main }); module.exports = __toCommonJS(src_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") }); 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); 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("my_dick - \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("avg_dick - \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("today_dick - \u67E5\u770B\u725B\u725B\u957F\u5EA6\u4ECA\u65E5\u6392\u884C").shortcut("\u4ECA\u65E5\u957F\u5EA6").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]); }); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { config, inject, lang, main });