koishi-plugin-echo-cave 1.24.2 → 1.24.4
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.
- package/README.md +16 -13
- package/lib/index.cjs +13 -17
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
- 🗑️ **消息管理**:支持删除特定 ID 的消息(消息存储者、原始发送者或管理员)
|
|
16
16
|
- 👤 **个人追踪**:支持查看自己投稿的消息列表
|
|
17
17
|
- 🔍 **发言回溯**:支持查看自己被他人投稿的消息列表
|
|
18
|
+
- 📊 **排行榜功能**:支持查看不同时间段内的回声洞排行榜
|
|
18
19
|
- 🎨 **模板化展示**:消息展示时自带多种风格的外部包裹信息
|
|
19
20
|
- 🔒 **管理员保护**:可配置管理员消息保护
|
|
20
21
|
- 📏 **媒体限制**:支持配置媒体文件大小限制
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
| `cave.purge <...ids>` | 批量删除多个 ID 的回声洞消息 | 消息存储者、原始发送者或管理员 |
|
|
33
34
|
| `cave.search <id>` | 搜索特定 ID 的回声洞消息 | 所有人 |
|
|
34
35
|
| `cave.bind <id> <...userIds>` | 将用户绑定到特定 ID 的回声洞 | 所有人 |
|
|
36
|
+
| `cave.rank [period]` | 查看回声洞排行榜,支持多种时间段 | 所有人 |
|
|
35
37
|
|
|
36
38
|
## 🚀 使用指南
|
|
37
39
|
|
|
@@ -45,19 +47,20 @@ npm install koishi-plugin-echo-cave
|
|
|
45
47
|
|
|
46
48
|
## 🛠️ 配置选项
|
|
47
49
|
|
|
48
|
-
| 配置项
|
|
49
|
-
|
|
50
|
-
| `adminMessageProtection`
|
|
51
|
-
| `allowContributorDelete`
|
|
52
|
-
| `allowSenderDelete`
|
|
53
|
-
| `deleteMediaWhenDeletingMsg` | boolean | `true`
|
|
54
|
-
| `enableSizeLimit`
|
|
55
|
-
| `maxImageSize`
|
|
56
|
-
| `maxVideoSize`
|
|
57
|
-
| `maxFileSize`
|
|
58
|
-
| `maxRecordSize`
|
|
59
|
-
| `useBase64ForMedia`
|
|
60
|
-
| `sendAllAsForwardMsg`
|
|
50
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
51
|
+
|------------------------------|---------|---------|-------------------------------|
|
|
52
|
+
| `adminMessageProtection` | boolean | `false` | 开启管理员消息保护,使管理员发布的消息只能由其他管理员删除 |
|
|
53
|
+
| `allowContributorDelete` | boolean | `true` | 允许消息投稿者删除自己投稿的消息 |
|
|
54
|
+
| `allowSenderDelete` | boolean | `true` | 允许原始消息发送者删除自己被投稿的消息 |
|
|
55
|
+
| `deleteMediaWhenDeletingMsg` | boolean | `true` | 删除消息时是否同时删除媒体文件 |
|
|
56
|
+
| `enableSizeLimit` | boolean | `false` | 启用媒体文件大小限制 |
|
|
57
|
+
| `maxImageSize` | number | `2048` | 最大图片大小(KB) |
|
|
58
|
+
| `maxVideoSize` | number | `512` | 最大视频大小(KB) |
|
|
59
|
+
| `maxFileSize` | number | `512` | 最大文件大小(KB) |
|
|
60
|
+
| `maxRecordSize` | number | `512` | 最大录音大小(KB) |
|
|
61
|
+
| `useBase64ForMedia` | boolean | `false` | 是否使用 Base64 编码发送媒体文件 |
|
|
62
|
+
| `sendAllAsForwardMsg` | boolean | `false` | 是否将所有消息以转发消息形式发送 |
|
|
63
|
+
| `rankingTopCount` | number | `10` | 排行榜显示的用户数量 |
|
|
61
64
|
|
|
62
65
|
## 📝 注意事项
|
|
63
66
|
|
package/lib/index.cjs
CHANGED
|
@@ -269,6 +269,7 @@ function parseUserIds(userIds) {
|
|
|
269
269
|
var import_axios = __toESM(require("axios"), 1);
|
|
270
270
|
var import_node_fs = require("node:fs");
|
|
271
271
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
272
|
+
var import_uuid = require("uuid");
|
|
272
273
|
async function saveMedia(ctx, mediaElement, type, cfg) {
|
|
273
274
|
const mediaUrl = mediaElement.url;
|
|
274
275
|
const originalMediaName = mediaElement.file;
|
|
@@ -277,7 +278,7 @@ async function saveMedia(ctx, mediaElement, type, cfg) {
|
|
|
277
278
|
return i === -1 ? type === "image" ? "png" : type === "video" ? "mp4" : type === "record" ? "mp3" : "bin" : originalMediaName.slice(i + 1).toLowerCase();
|
|
278
279
|
})();
|
|
279
280
|
const mediaDir = import_node_path.default.join(ctx.baseDir, "data", "cave", type + "s");
|
|
280
|
-
const mediaName =
|
|
281
|
+
const mediaName = (0, import_uuid.v4)().replace(/-/g, "");
|
|
281
282
|
const fullMediaPath = import_node_path.default.join(mediaDir, `${mediaName}.${ext}`);
|
|
282
283
|
ctx.logger.info(`Saving ${type} from ${mediaUrl} -> ${fullMediaPath}`);
|
|
283
284
|
try {
|
|
@@ -909,34 +910,29 @@ var PREDEFINED_PERIODS = [
|
|
|
909
910
|
];
|
|
910
911
|
var TIME_UNITS = {
|
|
911
912
|
m: 30 * 24 * 60 * 60 * 1e3,
|
|
912
|
-
// 月(按约 30 天算)
|
|
913
913
|
w: 7 * 24 * 60 * 60 * 1e3,
|
|
914
|
-
// 周
|
|
915
914
|
d: 24 * 60 * 60 * 1e3,
|
|
916
|
-
// 天
|
|
917
915
|
h: 60 * 60 * 1e3
|
|
918
|
-
// 小时
|
|
919
916
|
};
|
|
920
917
|
function parseCustomTime(timeStr) {
|
|
918
|
+
if (!timeStr || typeof timeStr !== "string") return null;
|
|
919
|
+
const s = timeStr.toLowerCase();
|
|
920
|
+
if (!/^(\d+(m|w|d|h))+$/i.test(s)) return null;
|
|
921
921
|
const regex = /(\d+)([mwdh])/g;
|
|
922
922
|
let match;
|
|
923
923
|
let totalMs = 0;
|
|
924
|
-
let lastUnit = "";
|
|
925
924
|
const unitOrder = ["m", "w", "d", "h"];
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
const [, value, unit] = match;
|
|
931
|
-
const num = parseInt(value, 10);
|
|
925
|
+
let lastIndex = -1;
|
|
926
|
+
while ((match = regex.exec(s)) !== null) {
|
|
927
|
+
const value = parseInt(match[1], 10);
|
|
928
|
+
const unit = match[2].toLowerCase();
|
|
932
929
|
const currentIndex = unitOrder.indexOf(unit);
|
|
933
|
-
|
|
934
|
-
if (
|
|
935
|
-
if (lastUnit && currentIndex > lastIndex) {
|
|
930
|
+
if (currentIndex === -1) return null;
|
|
931
|
+
if (lastIndex !== -1 && currentIndex < lastIndex) {
|
|
936
932
|
return null;
|
|
937
933
|
}
|
|
938
|
-
totalMs +=
|
|
939
|
-
|
|
934
|
+
totalMs += value * (TIME_UNITS[unit] ?? 0);
|
|
935
|
+
lastIndex = currentIndex;
|
|
940
936
|
}
|
|
941
937
|
return totalMs;
|
|
942
938
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-echo-cave",
|
|
3
3
|
"description": "Group echo cave",
|
|
4
|
-
"version": "1.24.
|
|
4
|
+
"version": "1.24.4",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@pynickle/koishi-plugin-adapter-onebot": "^1.0.0",
|
|
36
|
-
"axios": "^1.13.2"
|
|
36
|
+
"axios": "^1.13.2",
|
|
37
|
+
"uuid": "^13.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@semantic-release/changelog": "^6.0.3",
|