koishi-plugin-echo-cave 1.24.8 → 1.24.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,41 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name2 in all)
9
+ __defProp(target, name2, { get: all[name2], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.ts
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ Config: () => Config,
33
+ apply: () => apply,
34
+ inject: () => inject,
35
+ name: () => name
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+
1
39
  // src/adapters/onebot/user.ts
2
40
  async function getUserIdFromNickname(session, nickname, userId) {
3
41
  const memberInfos = await session.onebot.getGroupMemberList(session.channelId);
@@ -28,7 +66,7 @@ async function checkUsersInGroup(ctx, session, userIds) {
28
66
  }
29
67
 
30
68
  // src/utils/msg/element-helper.ts
31
- import { h } from "koishi";
69
+ var import_koishi = require("koishi");
32
70
  function parseUserIds(userIds) {
33
71
  const parsedUserIds = [];
34
72
  for (const userId of typeof userIds === "string" ? [userIds] : userIds) {
@@ -37,7 +75,7 @@ function parseUserIds(userIds) {
37
75
  parsedUserIds.push(userId);
38
76
  continue;
39
77
  }
40
- const element = h.parse(userId);
78
+ const element = import_koishi.h.parse(userId);
41
79
  if (element.length === 1 && element[0].type === "at") {
42
80
  const userId2 = element[0].attrs.id;
43
81
  if (userId2 === "all") {
@@ -55,10 +93,10 @@ function parseUserIds(userIds) {
55
93
  }
56
94
 
57
95
  // src/utils/media/media-helper.ts
58
- import axios from "axios";
59
- import { promises as fs } from "node:fs";
60
- import path from "node:path";
61
- import { v4 as uuidv4 } from "uuid";
96
+ var import_axios = __toESM(require("axios"), 1);
97
+ var import_node_fs = require("node:fs");
98
+ var import_node_path = __toESM(require("node:path"), 1);
99
+ var import_uuid = require("uuid");
62
100
  async function saveMedia(ctx, mediaElement, type, cfg) {
63
101
  const mediaUrl = mediaElement.url;
64
102
  const originalMediaName = mediaElement.file;
@@ -66,13 +104,13 @@ async function saveMedia(ctx, mediaElement, type, cfg) {
66
104
  const i = originalMediaName.lastIndexOf(".");
67
105
  return i === -1 ? type === "image" ? "png" : type === "video" ? "mp4" : type === "record" ? "mp3" : "bin" : originalMediaName.slice(i + 1).toLowerCase();
68
106
  })();
69
- const mediaDir = path.join(ctx.baseDir, "data", "cave", type + "s");
70
- const mediaName = uuidv4().replace(/-/g, "");
71
- const fullMediaPath = path.join(mediaDir, `${mediaName}.${ext}`);
107
+ const mediaDir = import_node_path.default.join(ctx.baseDir, "data", "cave", type + "s");
108
+ const mediaName = (0, import_uuid.v4)().replace(/-/g, "");
109
+ const fullMediaPath = import_node_path.default.join(mediaDir, `${mediaName}.${ext}`);
72
110
  ctx.logger.info(`Saving ${type} from ${mediaUrl} -> ${fullMediaPath}`);
73
111
  try {
74
- await fs.mkdir(mediaDir, { recursive: true });
75
- const res = await axios.get(mediaUrl, {
112
+ await import_node_fs.promises.mkdir(mediaDir, { recursive: true });
113
+ const res = await import_axios.default.get(mediaUrl, {
76
114
  responseType: "arraybuffer",
77
115
  validateStatus: () => true
78
116
  });
@@ -102,7 +140,7 @@ async function saveMedia(ctx, mediaElement, type, cfg) {
102
140
  ctx.logger.warn(`Downloaded ${type} buffer is empty`);
103
141
  return mediaUrl;
104
142
  }
105
- await fs.writeFile(fullMediaPath, buffer);
143
+ await import_node_fs.promises.writeFile(fullMediaPath, buffer);
106
144
  ctx.logger.info(
107
145
  `${type.charAt(0).toUpperCase() + type.slice(1)} saved successfully: ${fullMediaPath}`
108
146
  );
@@ -139,7 +177,7 @@ async function convertFileUriToBase64(ctx, element) {
139
177
  const fileUri = element.data.file;
140
178
  const filePath = decodeURIComponent(fileUri.replace("file:///", ""));
141
179
  try {
142
- const buffer = await fs.readFile(filePath);
180
+ const buffer = await import_node_fs.promises.readFile(filePath);
143
181
  const base64 = buffer.toString("base64");
144
182
  const mimeTypes = {
145
183
  image: "image/jpeg",
@@ -180,7 +218,7 @@ async function checkAndCleanMediaFiles(ctx, cfg, type) {
180
218
  if (!cfg.enableSizeLimit) {
181
219
  return;
182
220
  }
183
- const mediaDir = path.join(ctx.baseDir, "data", "cave", type + "s");
221
+ const mediaDir = import_node_path.default.join(ctx.baseDir, "data", "cave", type + "s");
184
222
  const maxSize = (() => {
185
223
  switch (type) {
186
224
  case "image":
@@ -195,14 +233,14 @@ async function checkAndCleanMediaFiles(ctx, cfg, type) {
195
233
  }
196
234
  })();
197
235
  try {
198
- const files = await fs.readdir(mediaDir);
236
+ const files = await import_node_fs.promises.readdir(mediaDir);
199
237
  if (files.length === 0) {
200
238
  return;
201
239
  }
202
240
  const fileInfos = await Promise.all(
203
241
  files.map(async (file) => {
204
- const filePath = path.join(mediaDir, file);
205
- const stats = await fs.stat(filePath);
242
+ const filePath = import_node_path.default.join(mediaDir, file);
243
+ const stats = await import_node_fs.promises.stat(filePath);
206
244
  return {
207
245
  path: filePath,
208
246
  size: stats.size,
@@ -229,9 +267,9 @@ async function checkAndCleanMediaFiles(ctx, cfg, type) {
229
267
  currentSize -= file.size;
230
268
  }
231
269
  for (const file of filesToDelete) {
232
- await fs.unlink(file.path);
270
+ await import_node_fs.promises.unlink(file.path);
233
271
  ctx.logger.info(
234
- `Deleted oldest ${type} file: ${path.basename(file.path)} (${(file.size / (1024 * 1024)).toFixed(2)} MB)`
272
+ `Deleted oldest ${type} file: ${import_node_path.default.basename(file.path)} (${(file.size / (1024 * 1024)).toFixed(2)} MB)`
235
273
  );
236
274
  }
237
275
  ctx.logger.info(
@@ -249,8 +287,8 @@ async function deleteMediaFilesFromMessage(ctx, content) {
249
287
  if (fileUri && fileUri.startsWith("file:///")) {
250
288
  const filePath = decodeURIComponent(fileUri.replace("file:///", ""));
251
289
  try {
252
- await fs.access(filePath);
253
- await fs.unlink(filePath);
290
+ await import_node_fs.promises.access(filePath);
291
+ await import_node_fs.promises.unlink(filePath);
254
292
  ctx.logger.info(`Deleted media file: ${filePath}`);
255
293
  } catch (err) {
256
294
  ctx.logger.warn(`Failed to delete media file: ${filePath}, error: ${err}`);
@@ -320,7 +358,7 @@ async function processMessageContent(ctx, msg, cfg) {
320
358
  }
321
359
 
322
360
  // src/core/command/add-cave.ts
323
- import { CQCode } from "@pynickle/koishi-plugin-adapter-onebot";
361
+ var import_koishi_plugin_adapter_onebot = require("@pynickle/koishi-plugin-adapter-onebot");
324
362
  async function addCave(ctx, session, cfg, userIds) {
325
363
  if (!session.guildId) {
326
364
  return session.text("echo-cave.general.privateChatReminder");
@@ -360,7 +398,7 @@ async function addCave(ctx, session, cfg, userIds) {
360
398
  const message = (await session.onebot.getMsg(messageId)).message;
361
399
  let msgJson;
362
400
  if (typeof message === "string") {
363
- msgJson = CQCode.parse(message);
401
+ msgJson = import_koishi_plugin_adapter_onebot.CQCode.parse(message);
364
402
  } else {
365
403
  if (message[0].type === "video" || message[0].type === "file") {
366
404
  type = "forward";
@@ -1024,20 +1062,20 @@ var zh_CN_default2 = {
1024
1062
  };
1025
1063
 
1026
1064
  // src/config/config.ts
1027
- import { Schema } from "koishi";
1028
- var Config = Schema.object({
1029
- adminMessageProtection: Schema.boolean().default(false),
1030
- allowContributorDelete: Schema.boolean().default(true),
1031
- allowSenderDelete: Schema.boolean().default(true),
1032
- deleteMediaWhenDeletingMsg: Schema.boolean().default(true),
1033
- enableSizeLimit: Schema.boolean().default(false),
1034
- maxImageSize: Schema.number().default(2048),
1035
- maxVideoSize: Schema.number().default(512),
1036
- maxFileSize: Schema.number().default(512),
1037
- maxRecordSize: Schema.number().default(512),
1038
- useBase64ForMedia: Schema.boolean().default(false),
1039
- sendAllAsForwardMsg: Schema.boolean().default(false),
1040
- rankingTopCount: Schema.number().default(10)
1065
+ var import_koishi2 = require("koishi");
1066
+ var Config = import_koishi2.Schema.object({
1067
+ adminMessageProtection: import_koishi2.Schema.boolean().default(false),
1068
+ allowContributorDelete: import_koishi2.Schema.boolean().default(true),
1069
+ allowSenderDelete: import_koishi2.Schema.boolean().default(true),
1070
+ deleteMediaWhenDeletingMsg: import_koishi2.Schema.boolean().default(true),
1071
+ enableSizeLimit: import_koishi2.Schema.boolean().default(false),
1072
+ maxImageSize: import_koishi2.Schema.number().default(2048),
1073
+ maxVideoSize: import_koishi2.Schema.number().default(512),
1074
+ maxFileSize: import_koishi2.Schema.number().default(512),
1075
+ maxRecordSize: import_koishi2.Schema.number().default(512),
1076
+ useBase64ForMedia: import_koishi2.Schema.boolean().default(false),
1077
+ sendAllAsForwardMsg: import_koishi2.Schema.boolean().default(false),
1078
+ rankingTopCount: import_koishi2.Schema.number().default(10)
1041
1079
  }).i18n({
1042
1080
  "zh-CN": zh_CN_default2
1043
1081
  });
@@ -1117,9 +1155,10 @@ function apply(ctx, cfg) {
1117
1155
  async ({ session }, period) => await getRanking(ctx, session, cfg, period)
1118
1156
  );
1119
1157
  }
1120
- export {
1158
+ // Annotate the CommonJS export names for ESM import in node:
1159
+ 0 && (module.exports = {
1121
1160
  Config,
1122
1161
  apply,
1123
1162
  inject,
1124
1163
  name
1125
- };
1164
+ });
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "koishi-plugin-echo-cave",
3
3
  "description": "Group echo cave",
4
- "version": "1.24.8",
5
- "main": "lib/index.js",
4
+ "version": "1.24.9",
5
+ "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",
8
8
  "files": [
@@ -29,21 +29,12 @@
29
29
  ]
30
30
  },
31
31
  "peerDependencies": {
32
- "koishi": "^4.18.9",
33
- "@pynickle/koishi-plugin-adapter-onebot": "^1.0.0",
34
- "koishi-plugin-adapter-onebot": "*"
35
- },
36
- "peerDependenciesMeta": {
37
- "@pynickle/koishi-plugin-adapter-onebot": {
38
- "optional": true
39
- },
40
- "koishi-plugin-adapter-onebot": {
41
- "optional": true
42
- }
32
+ "koishi": "^4.18.9"
43
33
  },
44
34
  "dependencies": {
45
35
  "axios": "^1.13.2",
46
- "uuid": "^13.0.0"
36
+ "uuid": "^11.1.0",
37
+ "@pynickle/koishi-plugin-adapter-onebot": "^1.0.0"
47
38
  },
48
39
  "devDependencies": {
49
40
  "@semantic-release/changelog": "^6.0.3",