Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koishi-plugin-jrys-max

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koishi-plugin-jrys-max - npm Package Compare versions

Comparing version 0.3.10 to 0.3.11

lib/index/template2.txt

167

lib/index.js

@@ -47,2 +47,76 @@ var __create = Object.create;

var import_koishi_plugin_axlmly_role_playing_game = require("koishi-plugin-axlmly-role-playing-game");
// src/jrysmax.ts
var fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
function fnv1aHash(str) {
let hash = 2166136261;
for (let i = 0; i < str.length; i++) {
hash ^= str.charCodeAt(i);
hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
}
return hash >>> 0;
}
__name(fnv1aHash, "fnv1aHash");
var jrysmax = class {
static {
__name(this, "jrysmax");
}
constructor() {
}
async getJrys(uid) {
const etime = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0).toString();
let userId;
if (typeof uid === "number" || !isNaN(Number(uid))) {
userId = Number(uid);
} else {
if (uid) {
const hashInput = uid + etime;
userId = fnv1aHash(hashInput) % 1000000001;
} else {
const defaultInput = "Default Jrys" + etime;
userId = fnv1aHash(defaultInput) % 1000000001;
}
}
const todaySeed = userId * parseInt(etime) % 1000000001;
const randomFactor = Math.sin(todaySeed) * 1e4;
const todayJrys = Math.floor((randomFactor - Math.floor(randomFactor)) * 512);
return todayJrys;
}
seededRandom(seed) {
const x = Math.sin(seed) * 1e4;
return x - Math.floor(x);
}
// 抽取四个宜不宜
async getRandomObjects(jsonObject, uid) {
if (!Array.isArray(jsonObject) || jsonObject.length < 4) {
throw new Error("输入必须是一个包含至少四个对象的数组");
}
const seed = await this.getJrys(uid);
const randomIndexes = /* @__PURE__ */ new Set();
let counter = 0;
while (randomIndexes.size < 4) {
const randomIndex = Math.floor(this.seededRandom(seed + counter) * jsonObject.length);
randomIndexes.add(randomIndex);
counter++;
}
return Array.from(randomIndexes).map((index) => jsonObject[index]);
}
// 递归获取文件夹内所有文件的文件名
async readFilenames(dirPath) {
let filenames = [];
const files = fs.readdirSync(dirPath);
files.forEach((filename) => {
const fullPath = import_path.default.join(dirPath, filename);
if (fs.statSync(fullPath).isDirectory()) {
filenames = filenames.concat(this.readFilenames(fullPath));
} else {
filenames.push(filename);
}
});
return filenames;
}
};
// src/signin.ts
var timeGreetings = [

@@ -94,3 +168,5 @@ { range: [0, 5], message: "晚安" },

count: "unsigned",
current_point: "unsigned"
current_point: "unsigned",
coins: "unsigned",
exp: "unsigned"
});

@@ -110,2 +186,4 @@ }

name2 = name2.length > 12 ? name2.substring(0, 12) : name2;
const jrys = new jrysmax();
const jrysData = await jrys.getJrys(session.userId);
let signTime = import_koishi.Time.template("yyyy-MM-dd hh:mm:ss", /* @__PURE__ */ new Date());

@@ -133,3 +211,3 @@ let all_point = (await this.ctx.database.get("jrys_max", { id: String(session.userId) }))[0]?.point;

await ctx.axlmlyrpg.getdata(session, config, ctx);
await ctx.axlmlyrpg.updataconis(ctx, session);
await ctx.axlmlyrpg.updataconis(ctx, session, config, jrysData);
}

@@ -158,3 +236,3 @@ console.log(coins);

await ctx.axlmlyrpg.getdata(session, config, ctx);
await ctx.axlmlyrpg.updataconis(ctx, session);
await ctx.axlmlyrpg.updataconis(ctx, session, config, jrysData);
}

@@ -213,74 +291,2 @@ return {

// src/jrysmax.ts
var fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
function fnv1aHash(str) {
let hash = 2166136261;
for (let i = 0; i < str.length; i++) {
hash ^= str.charCodeAt(i);
hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
}
return hash >>> 0;
}
__name(fnv1aHash, "fnv1aHash");
var jrysmax = class {
static {
__name(this, "jrysmax");
}
constructor() {
}
async getJrys(uid) {
const etime = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0).toString();
let userId;
if (typeof uid === "number" || !isNaN(Number(uid))) {
userId = Number(uid);
} else {
if (uid) {
const hashInput = uid + etime;
userId = fnv1aHash(hashInput) % 1000000001;
} else {
const defaultInput = "Default Jrys" + etime;
userId = fnv1aHash(defaultInput) % 1000000001;
}
}
const todaySeed = userId * parseInt(etime) % 1000000001;
const randomFactor = Math.sin(todaySeed) * 1e4;
const todayJrys = Math.floor((randomFactor - Math.floor(randomFactor)) * 512);
return todayJrys;
}
seededRandom(seed) {
const x = Math.sin(seed) * 1e4;
return x - Math.floor(x);
}
// 抽取四个宜不宜
async getRandomObjects(jsonObject, uid) {
if (!Array.isArray(jsonObject) || jsonObject.length < 4) {
throw new Error("输入必须是一个包含至少四个对象的数组");
}
const seed = await this.getJrys(uid);
const randomIndexes = /* @__PURE__ */ new Set();
let counter = 0;
while (randomIndexes.size < 4) {
const randomIndex = Math.floor(this.seededRandom(seed + counter) * jsonObject.length);
randomIndexes.add(randomIndex);
counter++;
}
return Array.from(randomIndexes).map((index) => jsonObject[index]);
}
// 递归获取文件夹内所有文件的文件名
async readFilenames(dirPath) {
let filenames = [];
const files = fs.readdirSync(dirPath);
files.forEach((filename) => {
const fullPath = import_path.default.join(dirPath, filename);
if (fs.statSync(fullPath).isDirectory()) {
filenames = filenames.concat(this.readFilenames(fullPath));
} else {
filenames.push(filename);
}
});
return filenames;
}
};
// src/event.ts

@@ -1025,6 +1031,13 @@ var eventJson = [

const baddo = `${baddo1.name}——${baddo1.bad}<br>${baddo2.name}——${baddo2.bad}`;
let coins = (await ctx.database.get("jrys_max", { id: String(session.userId) }))[0]?.coins;
let exp = (await ctx.database.get("jrys_max", { id: String(session.userId) }))[0]?.exp;
let page;
try {
let templateHTML = import_fs.default.readFileSync(import_path3.default.resolve(__dirname, "./index/template.txt"), "utf-8");
let template = templateHTML.replace("##textfont##", textfont).replace("##todayExp##", getSigninJson.getpoint.toString()).replace("##totalExp##", getSigninJson.allpoint.toString()).replace("##jryslucky##", jryslucky).replace("##level##", levelname).replace("##color##", color).replace("##pointlevel##", allpoint_LevelLines).replace("##bgUrl##", bgUrl).replace("##avatarUrl##", session.platform == "qq" ? `http://q.qlogo.cn/qqapp/${session.bot.config.id}/${session.event.user?.id}/640` : session.author.avatar).replace("##signinText##", getSigninJson.status ? "签到成功!" : "今天已经签到过了哦~").replace("##date##", formattedDate).replace("##hello##", signin.getGreeting(date.getHours())).replace("##user##", name2).replace("##persent##", (Number(getSigninJson.allpoint) / lvline * 100).toFixed(3).toString()).replace("##signTxt##", hitokoto).replace("##fortunate##", fortune_text).replace("##luckystar##", fortune_star).replace("##gooddo##", gooddo).replace("##baddo##", baddo);
let templateHTML;
if (ctx.axlmlyrpg) {
templateHTML = import_fs.default.readFileSync(import_path3.default.resolve(__dirname, "./index/template2.txt"), "utf-8");
} else {
templateHTML = import_fs.default.readFileSync(import_path3.default.resolve(__dirname, "./index/template.txt"), "utf-8");
}
let template = templateHTML.replace("##textfont##", textfont).replace("##todayExp##", getSigninJson.getpoint.toString()).replace("##totalExp##", getSigninJson.allpoint.toString()).replace("##jryslucky##", jryslucky).replace("##level##", levelname).replace("##color##", color).replace("##pointlevel##", allpoint_LevelLines).replace("##bgUrl##", bgUrl).replace("##coins##", coins).replace("##exp##", exp).replace("##avatarUrl##", session.platform == "qq" ? `http://q.qlogo.cn/qqapp/${session.bot.config.id}/${session.event.user?.id}/640` : session.author.avatar).replace("##signinText##", getSigninJson.status ? "签到成功!" : "今天已经签到过了哦~").replace("##date##", formattedDate).replace("##hello##", signin.getGreeting(date.getHours())).replace("##user##", name2).replace("##persent##", (Number(getSigninJson.allpoint) / lvline * 100).toFixed(3).toString()).replace("##signTxt##", hitokoto).replace("##fortunate##", fortune_text).replace("##luckystar##", fortune_star).replace("##gooddo##", gooddo).replace("##baddo##", baddo);
await import_fs.default.writeFileSync(import_path3.default.resolve(__dirname, "./index/index.html"), template);

@@ -1031,0 +1044,0 @@ page = await ctx.puppeteer.page();

@@ -14,2 +14,4 @@ import { Context } from 'koishi';

current_point: number;
coins: number;
exp: number;
}

@@ -16,0 +18,0 @@ interface LevelInfo {

{
"name": "koishi-plugin-jrys-max",
"description": "",
"version": "0.3.10",
"version": "0.3.11",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "typings": "lib/index.d.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc