koishi-plugin-echo-cave 1.17.0 → 1.18.1

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 CHANGED
@@ -55,25 +55,9 @@ npm install koishi-plugin-echo-cave
55
55
  5. **查看自己的投稿**:发送命令 `cave.listen` 查看自己曾经存入的所有回声洞消息
56
56
  6. **查看自己的发言**:发送命令 `cave.trace` 查看自己曾经被他人存入的回声洞消息
57
57
 
58
- ## 📁 文件结构
59
-
60
- ```
61
- src/
62
- ├── index.ts # 插件主入口,命令注册和核心功能
63
- ├── cave-helper.ts # 回声洞消息发送辅助函数
64
- ├── forward-helper.ts # 转发消息处理辅助函数
65
- ├── media-helper.ts # 媒体文件保存辅助函数
66
- ├── msg-helper.ts # 消息发送辅助函数
67
- ├── cqcode-helper.ts # CQ 码处理辅助函数
68
- ├── onebot-helper.ts # OneBot 适配器辅助函数
69
- └── locales/
70
- └── zh-CN.json # 中文语言包
71
- ```
72
-
73
58
  ## 🔧 技术说明
74
59
 
75
60
  - 插件使用 Koishi 数据库系统存储消息记录
76
- - 图片会保存在 `data/cave/images` 目录下
77
61
  - 支持嵌套转发消息的处理
78
62
  - 自动检测重复消息,避免存储重复内容
79
63
  - 支持媒体文件大小限制
@@ -82,15 +66,15 @@ src/
82
66
 
83
67
  ## 🛠️ 配置选项
84
68
 
85
- | 配置项 | 类型 | 默认值 | 说明 |
86
- |-------|------|-------|------|
69
+ | 配置项 | 类型 | 默认值 | 说明 |
70
+ |--------------------------|---------|---------|-------------------------------|
87
71
  | `adminMessageProtection` | boolean | `false` | 开启管理员消息保护,使管理员发布的消息只能由其他管理员删除 |
88
- | `allowContributorDelete` | boolean | `true` | 允许消息投稿者删除自己投稿的消息 |
89
- | `allowSenderDelete` | boolean | `true` | 允许原始消息发送者删除自己被投稿的消息 |
90
- | `enableSizeLimit` | boolean | `false` | 启用媒体文件大小限制 |
91
- | `maxImageSize` | number | `2048` | 最大图片大小(KB) |
92
- | `maxVideoSize` | number | `512` | 最大视频大小(MB) |
93
- | `maxFileSize` | number | `512` | 最大文件大小(MB) |
72
+ | `allowContributorDelete` | boolean | `true` | 允许消息投稿者删除自己投稿的消息 |
73
+ | `allowSenderDelete` | boolean | `true` | 允许原始消息发送者删除自己被投稿的消息 |
74
+ | `enableSizeLimit` | boolean | `false` | 启用媒体文件大小限制 |
75
+ | `maxImageSize` | number | `2048` | 最大图片大小(KB) |
76
+ | `maxVideoSize` | number | `512` | 最大视频大小(MB) |
77
+ | `maxFileSize` | number | `512` | 最大文件大小(MB) |
94
78
 
95
79
  ## 📝 注意事项
96
80
 
@@ -1,4 +1,5 @@
1
1
  import { Context, Session } from 'koishi';
2
+ export declare function getUserIdFromNickname(session: Session, nickname: string, userId: number): Promise<number>;
2
3
  export declare function getUserName(ctx: Context, session: Session, userId: string): Promise<string>;
3
4
  /**
4
5
  * 检查用户是否属于指定群组
@@ -0,0 +1,14 @@
1
+ import { Schema } from 'koishi';
2
+ export interface Config {
3
+ adminMessageProtection?: boolean;
4
+ allowContributorDelete?: boolean;
5
+ allowSenderDelete?: boolean;
6
+ deleteMediaWhenDeletingMsg?: boolean;
7
+ enableSizeLimit?: boolean;
8
+ maxImageSize?: number;
9
+ maxVideoSize?: number;
10
+ maxFileSize?: number;
11
+ maxRecordSize?: number;
12
+ useBase64ForMedia?: boolean;
13
+ }
14
+ export declare const Config: Schema<Config>;
@@ -0,0 +1,3 @@
1
+ import { Config } from '../../config/config';
2
+ import { Context, Session } from 'koishi';
3
+ export declare function addCave(ctx: Context, session: Session, cfg: Config, userIds?: string[]): Promise<string>;
@@ -0,0 +1,4 @@
1
+ import { Config } from '../../config/config';
2
+ import { Context, Session } from 'koishi';
3
+ export declare function deleteCave(ctx: Context, session: Session, cfg: Config, id: number): Promise<string>;
4
+ export declare function deleteCaves(ctx: Context, session: Session, cfg: Config, ids: number[]): Promise<string>;
@@ -0,0 +1,5 @@
1
+ import { Config } from '../../config/config';
2
+ import { Context, Session } from 'koishi';
3
+ export declare function getCaveListByUser(ctx: Context, session: Session): Promise<string>;
4
+ export declare function getCaveListByOriginUser(ctx: Context, session: Session): Promise<string>;
5
+ export declare function getCave(ctx: Context, session: Session, cfg: Config, id: number): Promise<string>;
@@ -0,0 +1,2 @@
1
+ import { Context, Session } from 'koishi';
2
+ export declare function bindUsersToCave(ctx: Context, session: Session, id: number, userIds: string[]): Promise<string>;
@@ -0,0 +1,2 @@
1
+ import { Context, Session } from 'koishi';
2
+ export declare function searchCave(ctx: Context, session: Session, userIds: number): Promise<string>;
@@ -1,4 +1,5 @@
1
- import { Config, EchoCave } from './index';
1
+ import { Config } from '../../config/config';
2
+ import { EchoCave } from '../../index';
2
3
  import { Context, Session } from 'koishi';
3
4
  export declare function sendCaveMsg(ctx: Context, session: Session, caveMsg: EchoCave, cfg: Config): Promise<void>;
4
5
  export declare function formatDate(date: Date): string;
@@ -1,4 +1,4 @@
1
- import { Config } from './index';
1
+ import { Config } from '../../config/config';
2
2
  import { CQCode } from '@pynickle/koishi-plugin-adapter-onebot';
3
3
  import { Message } from '@pynickle/koishi-plugin-adapter-onebot/lib/types';
4
4
  import { Context, Session } from 'koishi';
@@ -1,4 +1,4 @@
1
- import { Config } from './index';
1
+ import { Config } from '../../config/config';
2
2
  import { CQCode } from '@pynickle/koishi-plugin-adapter-onebot';
3
3
  import { Context } from 'koishi';
4
4
  export declare function processMessageContent(ctx: Context, msg: CQCode[], cfg: Config): Promise<CQCode[]>;
package/lib/index.cjs CHANGED
@@ -51,6 +51,10 @@ var require_zh_CN = __commonJS({
51
51
  noMsgWithId: "\u{1F50D} \u672A\u627E\u5230\u8BE5 ID \u7684\u56DE\u58F0\u6D1E\u6D88\u606F",
52
52
  noTemplatesConfigured: "\u274C \u672A\u914D\u7F6E\u56DE\u58F0\u6D1E\u6A21\u677F\uFF0C\u8BF7\u5148\u914D\u7F6E\u6A21\u677F\uFF01"
53
53
  },
54
+ user: {
55
+ invalidAllMention: "\u274C \u4E0D\u652F\u6301 @\u5168\u4F53\u6210\u5458\uFF0C\u8BF7\u76F4\u63A5\u6307\u5B9A\u5177\u4F53\u7528\u6237\uFF01",
56
+ userNotInGroup: "\u274C \u63D0\u4F9B\u7684\u7528\u6237 ID \u4E0D\u5168\u5C5E\u4E8E\u8BE5\u7FA4\u7EC4\uFF01"
57
+ },
54
58
  templates: {
55
59
  forward: [
56
60
  "\u{1F300} \u56DE\u58F0\u6D1E #{id}\n\n\u4E00\u5219\u56DE\u58F0\u4ECE\u65F6\u5149\u4E2D\u98D8\u6765\u2014\u2014\n\u{1F4C5} {date} \xB7 \u6765\u81EA @{originName} \n\u{1F4EE} \u7531 @{userName} \u6295\u9012",
@@ -96,9 +100,7 @@ var require_zh_CN = __commonJS({
96
100
  noMsgQuoted: "\u{1F4A1} \u8BF7\u5F15\u7528\u4E00\u6761\u6D88\u606F\u540E\u518D\u4F7F\u7528\u6B64\u547D\u4EE4\uFF01",
97
101
  existingMsg: "\u267B\uFE0F \u8BE5\u6D88\u606F\u5DF2\u5B58\u5728\u4E8E\u56DE\u58F0\u6D1E\u7A74\u4E2D\uFF01",
98
102
  msgSaved: "\u2705 \u56DE\u58F0\u6D1E\u6D88\u606F\u5DF2\u6210\u529F\u5B58\u5165\uFF0C\u6D88\u606F ID\uFF1A{0}",
99
- msgFailedToSave: "\u274C \u56DE\u58F0\u6D1E\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF01",
100
- userNotInGroup: "\u274C \u63D0\u4F9B\u7684\u7528\u6237 ID \u4E0D\u5168\u5C5E\u4E8E\u8BE5\u7FA4\u7EC4\uFF01",
101
- invalidAllMention: "\u274C \u4E0D\u652F\u6301 @\u5168\u4F53\u6210\u5458\uFF0C\u8BF7\u76F4\u63A5\u6307\u5B9A\u5177\u4F53\u7528\u6237\uFF01"
103
+ msgFailedToSave: "\u274C \u56DE\u58F0\u6D1E\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\uFF01"
102
104
  }
103
105
  },
104
106
  "cave.drop": {
@@ -108,7 +110,8 @@ var require_zh_CN = __commonJS({
108
110
  adminOnly: "\u26D4 \u8BE5\u6D88\u606F\u7531\u7BA1\u7406\u5458\u53D1\u5E03\uFF0C\u5DF2\u5F00\u542F\u7BA1\u7406\u5458\u6D88\u606F\u4FDD\u62A4\uFF0C\u53EA\u6709\u7BA1\u7406\u5458\u53EF\u4EE5\u5220\u9664\u3002",
109
111
  permissionDenied: "\u26D4 \u60A8\u6CA1\u6709\u6743\u9650\u5220\u9664\u6B64\u6D88\u606F\uFF01\u53EA\u6709\u7BA1\u7406\u5458\u53EF\u4EE5\u5220\u9664\u3002",
110
112
  contributorDeleteDenied: "\u26D4 \u60A8\u6CA1\u6709\u6743\u9650\u5220\u9664\u6B64\u6D88\u606F\uFF01\u5F53\u524D\u914D\u7F6E\u4E0D\u5141\u8BB8\u6295\u7A3F\u8005\u5220\u9664\u56DE\u58F0\u6D1E\u3002",
111
- senderDeleteDenied: "\u26D4 \u60A8\u6CA1\u6709\u6743\u9650\u5220\u9664\u6B64\u6D88\u606F\uFF01\u5F53\u524D\u914D\u7F6E\u4E0D\u5141\u8BB8\u539F\u59CB\u53D1\u9001\u8005\u5220\u9664\u56DE\u58F0\u6D1E\u3002"
113
+ senderDeleteDenied: "\u26D4 \u60A8\u6CA1\u6709\u6743\u9650\u5220\u9664\u6B64\u6D88\u606F\uFF01\u5F53\u524D\u914D\u7F6E\u4E0D\u5141\u8BB8\u539F\u59CB\u53D1\u9001\u8005\u5220\u9664\u56DE\u58F0\u6D1E\u3002",
114
+ msgDeleted: "\u2705 \u5DF2\u6210\u529F\u62B9\u53BB\u56DE\u58F0\u6D1E\u6D88\u606F ID\uFF1A{0}"
112
115
  }
113
116
  },
114
117
  "cave.purge": {
@@ -125,8 +128,6 @@ var require_zh_CN = __commonJS({
125
128
  description: "\u641C\u7D22\u4E0E\u6307\u5B9A\u7528\u6237\u76F8\u5173\u7684\u56DE\u58F0\u6D1E",
126
129
  messages: {
127
130
  noUserIdProvided: "\u274C \u8BF7\u63D0\u4F9B\u8981\u641C\u7D22\u7684\u7528\u6237 ID\uFF01",
128
- invalidAllMention: "\u274C \u4E0D\u652F\u6301 @\u5168\u4F53\u6210\u5458\uFF0C\u8BF7\u76F4\u63A5\u6307\u5B9A\u5177\u4F53\u7528\u6237\uFF01",
129
- userNotInGroup: "\u274C \u63D0\u4F9B\u7684\u7528\u6237 ID \u4E0D\u5168\u5C5E\u4E8E\u8BE5\u7FA4\u7EC4\uFF01",
130
131
  noValidUserIdProvided: "\u274C \u672A\u63D0\u4F9B\u6709\u6548\u7684\u7528\u6237 ID\uFF01",
131
132
  noMatchingCaves: "\u{1F50D} \u672A\u627E\u5230\u4E0E\u7528\u6237 {0} \u76F8\u5173\u7684\u56DE\u58F0\u6D1E\u6D88\u606F",
132
133
  searchResult: "\u{1F50D} \u5171\u627E\u5230 {0} \u6761\u4E0E\u8BE5\u7528\u6237\u76F8\u5173\u7684\u56DE\u58F0\u6D1E\u6D88\u606F\uFF1A\nID \u5217\u8868\uFF1A{1}"
@@ -136,16 +137,16 @@ var require_zh_CN = __commonJS({
136
137
  description: "\u83B7\u5F97\u7531\u81EA\u5DF1\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E\u5217\u8868",
137
138
  messages: {
138
139
  noMsgContributed: '\u{1F680} \u60A8\u5728\u56DE\u58F0\u6D1E\u4E2D\u6682\u65E0\u6295\u7A3F\uFF0C\u5FEB\u4F7F\u7528 "cave.echo" \u547D\u4EE4\u6DFB\u52A0\u7B2C\u4E00\u6761\u6D88\u606F\u5427\uFF01',
139
- msgListHeader: "\u{1F4DC} \u60A8\u5728\u672C\u9891\u9053\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E\u6D88\u606F\u5217\u8868\uFF1A\n",
140
- msgListItem: "ID: {0} | \u521B\u5EFA\u65F6\u95F4: {1}\n"
140
+ msgListHeader: "\u{1F4DC} \u60A8\u5728\u672C\u9891\u9053\u6295\u7A3F\u7684\u56DE\u58F0\u6D1E\u6D88\u606F\u5217\u8868\uFF1A",
141
+ msgListItem: "ID: {0} | \u521B\u5EFA\u65F6\u95F4: {1}"
141
142
  }
142
143
  },
143
144
  "cave.trace": {
144
145
  description: "\u83B7\u5F97\u81EA\u5DF1\u53D1\u8A00\u7684\u56DE\u58F0\u6D1E\u5217\u8868",
145
146
  messages: {
146
147
  noMsgTraced: '\u{1F680} \u60A8\u5728\u56DE\u58F0\u6D1E\u4E2D\u6682\u65E0\u53D1\u8A00\u88AB\u6295\u7A3F\uFF0C\u5FEB\u4F7F\u7528 "cave.echo" \u547D\u4EE4\u6DFB\u52A0\u7B2C\u4E00\u6761\u6D88\u606F\u5427\uFF01',
147
- msgListHeader: "\u{1F4DC} \u60A8\u5728\u672C\u9891\u9053\u53D1\u8A00\u7684\u56DE\u58F0\u6D1E\u6D88\u606F\u5217\u8868\uFF1A\n",
148
- msgListItem: "ID: {0} | \u521B\u5EFA\u65F6\u95F4: {1}\n"
148
+ msgListHeader: "\u{1F4DC} \u60A8\u5728\u672C\u9891\u9053\u53D1\u8A00\u7684\u56DE\u58F0\u6D1E\u6D88\u606F\u5217\u8868\uFF1A",
149
+ msgListItem: "ID: {0} | \u521B\u5EFA\u65F6\u95F4: {1}"
149
150
  }
150
151
  },
151
152
  "cave.bind": {
@@ -154,9 +155,7 @@ var require_zh_CN = __commonJS({
154
155
  noIdProvided: "\u274C \u8BF7\u63D0\u4F9B\u8981\u7ED1\u5B9A\u7528\u6237\u7684\u56DE\u58F0\u6D1E\u6D88\u606F ID\uFF01",
155
156
  noUserIdProvided: "\u274C \u8BF7\u63D0\u4F9B\u8981\u7ED1\u5B9A\u7684\u7528\u6237 ID\uFF01",
156
157
  msgNotFound: "\u{1F50D} \u672A\u627E\u5230\u8BE5 ID \u7684\u56DE\u58F0\u6D1E\u6D88\u606F",
157
- userBoundSuccess: "\u2705 \u5DF2\u6210\u529F\u5C06\u7528\u6237\u7ED1\u5B9A\u5230\u56DE\u58F0\u6D1E #{0}\uFF01",
158
- userNotInGroup: "\u274C \u63D0\u4F9B\u7684\u7528\u6237 ID \u4E0D\u5168\u5C5E\u4E8E\u8BE5\u7FA4\u7EC4\uFF01",
159
- invalidAllMention: "\u274C \u4E0D\u652F\u6301 @\u5168\u4F53\u6210\u5458\uFF0C\u8BF7\u76F4\u63A5\u6307\u5B9A\u5177\u4F53\u7528\u6237\uFF01"
158
+ userBoundSuccess: "\u2705 \u5DF2\u6210\u529F\u5C06\u7528\u6237\u7ED1\u5B9A\u5230\u56DE\u58F0\u6D1E #{0}\uFF01"
160
159
  }
161
160
  }
162
161
  }
@@ -167,24 +166,44 @@ var require_zh_CN = __commonJS({
167
166
  // src/index.ts
168
167
  var index_exports = {};
169
168
  __export(index_exports, {
170
- Config: () => Config,
171
169
  apply: () => apply,
172
170
  inject: () => inject,
173
171
  name: () => name
174
172
  });
175
173
  module.exports = __toCommonJS(index_exports);
176
- var import_koishi_plugin_adapter_onebot = require("@pynickle/koishi-plugin-adapter-onebot");
174
+ var import_koishi_plugin_adapter_onebot2 = require("@pynickle/koishi-plugin-adapter-onebot");
177
175
 
178
- // src/cqcode-helper.ts
179
- var import_koishi = require("koishi");
180
- function createTextMsg(content) {
181
- return {
182
- type: "text",
183
- data: {
184
- text: content
185
- }
186
- };
176
+ // src/adapters/onebot/user.ts
177
+ async function getUserIdFromNickname(session, nickname, userId) {
178
+ const memberInfos = await session.onebot.getGroupMemberList(session.channelId);
179
+ const matches = memberInfos.filter((m) => m.nickname === nickname);
180
+ if (matches.length === 1) {
181
+ return matches[0].user_id;
182
+ }
183
+ return userId;
184
+ }
185
+ async function getUserName(ctx, session, userId) {
186
+ try {
187
+ const memberInfo = await session.onebot.getGroupMemberInfo(session.channelId, userId);
188
+ return memberInfo.card || memberInfo.nickname || userId;
189
+ } catch (error) {
190
+ ctx.logger.warn(`Failed to get group member info (userId: ${userId}):`, error);
191
+ return userId;
192
+ }
193
+ }
194
+ async function checkUsersInGroup(ctx, session, userIds) {
195
+ try {
196
+ const groupMembers = await session.onebot.getGroupMemberList(session.channelId);
197
+ const memberIds = groupMembers.map((member) => member.user_id.toString());
198
+ return userIds.every((userId) => memberIds.includes(userId));
199
+ } catch (error) {
200
+ ctx.logger.warn(`Failed to get group member list:`, error);
201
+ return false;
202
+ }
187
203
  }
204
+
205
+ // src/utils/msg/element-helper.ts
206
+ var import_koishi = require("koishi");
188
207
  function parseUserIds(userIds) {
189
208
  const parsedUserIds = [];
190
209
  for (const userId of userIds) {
@@ -210,7 +229,7 @@ function parseUserIds(userIds) {
210
229
  };
211
230
  }
212
231
 
213
- // src/media-helper.ts
232
+ // src/utils/media/media-helper.ts
214
233
  var import_axios = __toESM(require("axios"), 1);
215
234
  var import_node_fs = require("node:fs");
216
235
  var import_node_path = __toESM(require("node:path"), 1);
@@ -408,100 +427,7 @@ async function deleteMediaFilesFromMessage(ctx, content) {
408
427
  }
409
428
  }
410
429
 
411
- // src/onebot-helper.ts
412
- async function getUserName(ctx, session, userId) {
413
- try {
414
- const memberInfo = await session.onebot.getGroupMemberInfo(session.channelId, userId);
415
- return memberInfo.card || memberInfo.nickname || userId;
416
- } catch (error) {
417
- ctx.logger.warn(`Failed to get group member info (userId: ${userId}):`, error);
418
- return userId;
419
- }
420
- }
421
- async function checkUsersInGroup(ctx, session, userIds) {
422
- try {
423
- const groupMembers = await session.onebot.getGroupMemberList(session.channelId);
424
- const memberIds = groupMembers.map((member) => member.user_id.toString());
425
- return userIds.every((userId) => memberIds.includes(userId));
426
- } catch (error) {
427
- ctx.logger.warn(`Failed to get group member list:`, error);
428
- return false;
429
- }
430
- }
431
-
432
- // src/cave-helper.ts
433
- async function sendCaveMsg(ctx, session, caveMsg, cfg) {
434
- const { channelId } = session;
435
- let content = JSON.parse(caveMsg.content);
436
- if (cfg.useBase64ForMedia) {
437
- content = await Promise.all(
438
- content.map(async (element) => await convertFileUriToBase64(ctx, element))
439
- );
440
- }
441
- const date = formatDate(caveMsg.createTime);
442
- const originName = await getUserName(ctx, session, caveMsg.originUserId);
443
- const userName = await getUserName(ctx, session, caveMsg.userId);
444
- let relatedUsersFormatted = originName;
445
- if (caveMsg.relatedUsers && caveMsg.relatedUsers.length > 0) {
446
- const relatedUserNames = await Promise.all(
447
- caveMsg.relatedUsers.map(async (userId) => await getUserName(ctx, session, userId))
448
- );
449
- relatedUsersFormatted = relatedUserNames.join(", ");
450
- }
451
- const templateData = {
452
- id: caveMsg.id.toString(),
453
- date,
454
- originName,
455
- userName,
456
- relatedUsers: relatedUsersFormatted,
457
- nl: "\n"
458
- };
459
- const TEMPLATE_COUNT = 5;
460
- if (caveMsg.type === "forward") {
461
- const availableTemplates2 = [];
462
- for (let i = 0; i < TEMPLATE_COUNT; i++) {
463
- const template = session.text(`echo-cave.templates.forward.${i}`, templateData);
464
- if (template.trim() !== "") {
465
- availableTemplates2.push(template);
466
- }
467
- }
468
- if (availableTemplates2.length === 0) {
469
- await session.send(session.text("echo-cave.general.noTemplatesConfigured"));
470
- return;
471
- }
472
- const chosenTemplate2 = availableTemplates2[Math.floor(Math.random() * availableTemplates2.length)];
473
- await session.onebot.sendGroupMsg(channelId, [createTextMsg(chosenTemplate2)]);
474
- await session.onebot.sendGroupForwardMsg(channelId, content);
475
- return;
476
- }
477
- const availableTemplates = [];
478
- for (let i = 0; i < TEMPLATE_COUNT; i++) {
479
- const prefix = session.text(`echo-cave.templates.msg.${i}.prefix`, templateData);
480
- const suffix = session.text(`echo-cave.templates.msg.${i}.suffix`, templateData);
481
- if (prefix.trim() !== "" && suffix.trim() !== "") {
482
- availableTemplates.push({ prefix, suffix });
483
- }
484
- }
485
- if (availableTemplates.length === 0) {
486
- await session.send(session.text("echo-cave.general.noTemplatesConfigured"));
487
- return;
488
- }
489
- const chosenTemplate = availableTemplates[Math.floor(Math.random() * availableTemplates.length)];
490
- const last = content.at(-1);
491
- const needsNewline = last?.type === "text";
492
- content.unshift(createTextMsg(chosenTemplate.prefix));
493
- content.push(createTextMsg(`${needsNewline ? "\n\n" : ""}${chosenTemplate.suffix}`));
494
- await session.onebot.sendGroupMsg(channelId, content);
495
- }
496
- function formatDate(date) {
497
- return date.toLocaleDateString("zh-CN", {
498
- year: "numeric",
499
- month: "2-digit",
500
- day: "2-digit"
501
- });
502
- }
503
-
504
- // src/forward-helper.ts
430
+ // src/core/parser/forward-parser.ts
505
431
  async function reconstructForwardMsg(ctx, session, message, cfg) {
506
432
  return Promise.all(
507
433
  message.map(async (msg) => {
@@ -520,14 +446,6 @@ async function reconstructForwardMsg(ctx, session, message, cfg) {
520
446
  })
521
447
  );
522
448
  }
523
- async function getUserIdFromNickname(session, nickname, userId) {
524
- const memberInfos = await session.onebot.getGroupMemberList(session.channelId);
525
- const matches = memberInfos.filter((m) => m.nickname === nickname);
526
- if (matches.length === 1) {
527
- return matches[0].user_id;
528
- }
529
- return userId;
530
- }
531
449
  async function processForwardMessageContent(ctx, session, msg, cfg) {
532
450
  if (typeof msg.message === "string") {
533
451
  return msg.message;
@@ -543,7 +461,7 @@ async function processForwardMessageContent(ctx, session, msg, cfg) {
543
461
  );
544
462
  }
545
463
 
546
- // src/msg-helper.ts
464
+ // src/core/parser/msg-parser.ts
547
465
  async function processMessageContent(ctx, msg, cfg) {
548
466
  return Promise.all(
549
467
  msg.map(async (element) => {
@@ -555,135 +473,83 @@ async function processMessageContent(ctx, msg, cfg) {
555
473
  );
556
474
  }
557
475
 
558
- // src/index.ts
559
- var import_koishi_plugin_adapter_onebot2 = require("@pynickle/koishi-plugin-adapter-onebot");
560
- var import_koishi2 = require("koishi");
561
- var name = "echo-cave";
562
- var inject = ["database"];
563
- var Config = import_koishi2.Schema.object({
564
- adminMessageProtection: import_koishi2.Schema.boolean().default(false),
565
- allowContributorDelete: import_koishi2.Schema.boolean().default(true),
566
- allowSenderDelete: import_koishi2.Schema.boolean().default(true),
567
- deleteMediaWhenDeletingMsg: import_koishi2.Schema.boolean().default(true),
568
- enableSizeLimit: import_koishi2.Schema.boolean().default(false),
569
- maxImageSize: import_koishi2.Schema.number().default(2048),
570
- maxVideoSize: import_koishi2.Schema.number().default(512),
571
- maxFileSize: import_koishi2.Schema.number().default(512),
572
- maxRecordSize: import_koishi2.Schema.number().default(512),
573
- useBase64ForMedia: import_koishi2.Schema.boolean().default(false)
574
- }).i18n({
575
- "zh-CN": require_zh_CN()._config
576
- });
577
- function apply(ctx, cfg) {
578
- ctx.i18n.define("zh-CN", require_zh_CN());
579
- ctx.model.extend(
580
- "echo_cave",
581
- {
582
- id: "unsigned",
583
- channelId: "string",
584
- createTime: "timestamp",
585
- userId: "string",
586
- originUserId: "string",
587
- type: "string",
588
- content: "text",
589
- relatedUsers: "list"
590
- },
591
- {
592
- primary: "id",
593
- autoInc: true
594
- }
595
- );
596
- ctx.command("cave [id:number]").action(
597
- async ({ session }, id) => await getCave(ctx, session, cfg, id)
598
- );
599
- ctx.command("cave.echo [...userIds]").action(
600
- async ({ session }, ...userIds) => await addCave(ctx, session, cfg, userIds)
601
- );
602
- ctx.command("cave.drop <id:number>").action(
603
- async ({ session }, id) => await deleteCave(ctx, session, cfg, id)
604
- );
605
- ctx.command("cave.purge <...ids:number>").action(
606
- async ({ session }, ...ids) => await deleteCaves(ctx, session, cfg, ids)
607
- );
608
- ctx.command("cave.search <...userIds>").action(
609
- async ({ session }, ...userIds) => await searchCave(ctx, session, userIds)
610
- );
611
- ctx.command("cave.listen").action(async ({ session }) => await getCaveListByUser(ctx, session));
612
- ctx.command("cave.trace").action(
613
- async ({ session }) => await getCaveListByOriginUser(ctx, session)
614
- );
615
- ctx.command("cave.bind <id:number> <...userIds>", { authority: 4 }).action(
616
- async ({ session }, id, ...userIds) => await bindUsersToCave(ctx, session, id, userIds)
617
- );
618
- }
619
- async function getCaveListByUser(ctx, session) {
620
- if (!session.guildId) {
621
- return session.text("echo-cave.general.privateChatReminder");
622
- }
623
- const { userId, channelId } = session;
624
- const caves = await ctx.database.get("echo_cave", {
625
- userId,
626
- channelId
627
- });
628
- if (caves.length === 0) {
629
- return session.text(".noMsgContributed");
630
- }
631
- let response = session.text(".msgListHeader");
632
- for (const cave of caves) {
633
- response += session.text(".msgListItem", [cave.id, formatDate(cave.createTime)]);
634
- }
635
- return response;
636
- }
637
- async function getCaveListByOriginUser(ctx, session) {
476
+ // src/core/command/add-cave.ts
477
+ var import_koishi_plugin_adapter_onebot = require("@pynickle/koishi-plugin-adapter-onebot");
478
+ async function addCave(ctx, session, cfg, userIds) {
638
479
  if (!session.guildId) {
639
480
  return session.text("echo-cave.general.privateChatReminder");
640
481
  }
641
- const { userId, channelId } = session;
642
- const caves = await ctx.database.get("echo_cave", {
643
- originUserId: userId,
644
- channelId
645
- });
646
- if (caves.length === 0) {
647
- return session.text(".noMsgTraced");
648
- }
649
- let response = session.text(".msgListHeader");
650
- for (const cave of caves) {
651
- response += session.text(".msgListItem", [cave.id, formatDate(cave.createTime)]);
652
- }
653
- return response;
654
- }
655
- async function getCave(ctx, session, cfg, id) {
656
- if (!session.guildId) {
657
- return session.text("echo-cave.general.privateChatReminder");
482
+ if (!session.quote) {
483
+ return session.text(".noMsgQuoted");
658
484
  }
659
- let caveMsg;
660
- const { channelId } = session;
661
- if (!id) {
662
- const caves = await ctx.database.get("echo_cave", {
663
- channelId
664
- });
665
- if (caves.length === 0) {
666
- return session.text(".noMsgInCave");
485
+ const { userId, channelId, quote } = session;
486
+ const messageId = quote.id;
487
+ let parsedUserIds = [];
488
+ if (userIds && userIds.length > 0) {
489
+ ctx.logger.info(`Original userIds in addCave: ${JSON.stringify(userIds)}`);
490
+ const result = parseUserIds(userIds);
491
+ if (result.error === "invalid_all_mention") {
492
+ return session.text("echo-cave.user.invalidAllMention");
667
493
  }
668
- caveMsg = caves[Math.floor(Math.random() * caves.length)];
669
- } else {
670
- const caves = await ctx.database.get("echo_cave", {
671
- id,
672
- channelId
673
- });
674
- if (caves.length === 0) {
675
- return session.text("echo-cave.general.noMsgWithId");
494
+ parsedUserIds = result.parsedUserIds;
495
+ const isAllUsersInGroup = await checkUsersInGroup(ctx, session, parsedUserIds);
496
+ if (!isAllUsersInGroup) {
497
+ return session.text(".userNotInGroup");
676
498
  }
677
- caveMsg = caves[0];
678
499
  }
679
- await sendCaveMsg(ctx, session, caveMsg, cfg);
680
- }
681
- async function deleteCave(ctx, session, cfg, id) {
682
- if (!session.guildId) {
683
- return session.text("echo-cave.general.privateChatReminder");
684
- }
685
- if (!id) {
686
- return session.text(".noIdProvided");
500
+ let content;
501
+ let type;
502
+ if (quote.elements[0].type === "forward") {
503
+ type = "forward";
504
+ const message = await reconstructForwardMsg(
505
+ ctx,
506
+ session,
507
+ await session.onebot.getForwardMsg(messageId),
508
+ cfg
509
+ );
510
+ content = JSON.stringify(message);
511
+ } else {
512
+ type = "msg";
513
+ const message = (await session.onebot.getMsg(messageId)).message;
514
+ let msgJson;
515
+ if (typeof message === "string") {
516
+ msgJson = import_koishi_plugin_adapter_onebot.CQCode.parse(message);
517
+ } else {
518
+ if (message[0].type === "video" || message[0].type === "file") {
519
+ type = "forward";
520
+ }
521
+ msgJson = message;
522
+ }
523
+ content = JSON.stringify(await processMessageContent(ctx, msgJson, cfg));
524
+ }
525
+ await ctx.database.get("echo_cave", { content }).then((existing) => {
526
+ if (existing) {
527
+ return session.text(".existingMsg");
528
+ }
529
+ });
530
+ try {
531
+ const result = await ctx.database.create("echo_cave", {
532
+ channelId,
533
+ createTime: /* @__PURE__ */ new Date(),
534
+ userId,
535
+ originUserId: quote.user.id,
536
+ type,
537
+ content,
538
+ relatedUsers: parsedUserIds || []
539
+ });
540
+ return session.text(".msgSaved", [result.id]);
541
+ } catch (error) {
542
+ return session.text(".msgFailedToSave");
543
+ }
544
+ }
545
+
546
+ // src/core/command/delete-cave.ts
547
+ async function deleteCave(ctx, session, cfg, id) {
548
+ if (!session.guildId) {
549
+ return session.text("echo-cave.general.privateChatReminder");
550
+ }
551
+ if (!id) {
552
+ return session.text(".noIdProvided");
687
553
  }
688
554
  const caves = await ctx.database.get("echo_cave", id);
689
555
  if (caves.length === 0) {
@@ -771,73 +637,154 @@ async function deleteCaves(ctx, session, cfg, ids) {
771
637
  return session.text(".msgDeletePartial", [failedIds.join(", ")]);
772
638
  }
773
639
  }
774
- async function addCave(ctx, session, cfg, userIds) {
775
- if (!session.guildId) {
776
- return session.text("echo-cave.general.privateChatReminder");
777
- }
778
- if (!session.quote) {
779
- return session.text(".noMsgQuoted");
780
- }
781
- const { userId, channelId, quote } = session;
782
- const messageId = quote.id;
783
- let parsedUserIds = [];
784
- if (userIds && userIds.length > 0) {
785
- ctx.logger.info(`Original userIds in addCave: ${JSON.stringify(userIds)}`);
786
- const result = parseUserIds(userIds);
787
- if (result.error === "invalid_all_mention") {
788
- return session.text(".invalidAllMention");
789
- }
790
- parsedUserIds = result.parsedUserIds;
791
- const isAllUsersInGroup = await checkUsersInGroup(ctx, session, parsedUserIds);
792
- if (!isAllUsersInGroup) {
793
- return session.text(".userNotInGroup");
640
+
641
+ // src/utils/msg/cqcode-helper.ts
642
+ function createTextMsg(content) {
643
+ return {
644
+ type: "text",
645
+ data: {
646
+ text: content
794
647
  }
648
+ };
649
+ }
650
+
651
+ // src/core/formatter/msg-formatter.ts
652
+ async function sendCaveMsg(ctx, session, caveMsg, cfg) {
653
+ const { channelId } = session;
654
+ let content = JSON.parse(caveMsg.content);
655
+ if (cfg.useBase64ForMedia) {
656
+ content = await Promise.all(
657
+ content.map(async (element) => await convertFileUriToBase64(ctx, element))
658
+ );
795
659
  }
796
- let content;
797
- let type;
798
- if (quote.elements[0].type === "forward") {
799
- type = "forward";
800
- const message = await reconstructForwardMsg(
801
- ctx,
802
- session,
803
- await session.onebot.getForwardMsg(messageId),
804
- cfg
660
+ const date = formatDate(caveMsg.createTime);
661
+ const originName = await getUserName(ctx, session, caveMsg.originUserId);
662
+ const userName = await getUserName(ctx, session, caveMsg.userId);
663
+ let relatedUsersFormatted = originName;
664
+ if (caveMsg.relatedUsers && caveMsg.relatedUsers.length > 0) {
665
+ const relatedUserNames = await Promise.all(
666
+ caveMsg.relatedUsers.map(async (userId) => await getUserName(ctx, session, userId))
805
667
  );
806
- content = JSON.stringify(message);
807
- } else {
808
- type = "msg";
809
- const message = (await session.onebot.getMsg(messageId)).message;
810
- let msgJson;
811
- if (typeof message === "string") {
812
- msgJson = import_koishi_plugin_adapter_onebot2.CQCode.parse(message);
813
- } else {
814
- if (message[0].type === "video" || message[0].type === "file") {
815
- type = "forward";
668
+ relatedUsersFormatted = relatedUserNames.join(", ");
669
+ }
670
+ const templateData = {
671
+ id: caveMsg.id.toString(),
672
+ date,
673
+ originName,
674
+ userName,
675
+ relatedUsers: relatedUsersFormatted,
676
+ nl: "\n"
677
+ };
678
+ const TEMPLATE_COUNT = 5;
679
+ if (caveMsg.type === "forward") {
680
+ const availableTemplates2 = [];
681
+ for (let i = 0; i < TEMPLATE_COUNT; i++) {
682
+ const template = session.text(`echo-cave.templates.forward.${i}`, templateData);
683
+ if (template.trim() !== "") {
684
+ availableTemplates2.push(template);
816
685
  }
817
- msgJson = message;
818
686
  }
819
- content = JSON.stringify(await processMessageContent(ctx, msgJson, cfg));
687
+ if (availableTemplates2.length === 0) {
688
+ await session.send(session.text("echo-cave.general.noTemplatesConfigured"));
689
+ return;
690
+ }
691
+ const chosenTemplate2 = availableTemplates2[Math.floor(Math.random() * availableTemplates2.length)];
692
+ await session.onebot.sendGroupMsg(channelId, [createTextMsg(chosenTemplate2)]);
693
+ await session.onebot.sendGroupForwardMsg(channelId, content);
694
+ return;
820
695
  }
821
- await ctx.database.get("echo_cave", { content }).then((existing) => {
822
- if (existing) {
823
- return session.text(".existingMsg");
696
+ const availableTemplates = [];
697
+ for (let i = 0; i < TEMPLATE_COUNT; i++) {
698
+ const prefix = session.text(`echo-cave.templates.msg.${i}.prefix`, templateData);
699
+ const suffix = session.text(`echo-cave.templates.msg.${i}.suffix`, templateData);
700
+ if (prefix.trim() !== "" && suffix.trim() !== "") {
701
+ availableTemplates.push({ prefix, suffix });
824
702
  }
703
+ }
704
+ if (availableTemplates.length === 0) {
705
+ await session.send(session.text("echo-cave.general.noTemplatesConfigured"));
706
+ return;
707
+ }
708
+ const chosenTemplate = availableTemplates[Math.floor(Math.random() * availableTemplates.length)];
709
+ const last = content.at(-1);
710
+ const needsNewline = last?.type === "text";
711
+ content.unshift(createTextMsg(chosenTemplate.prefix));
712
+ content.push(createTextMsg(`${needsNewline ? "\n\n" : ""}${chosenTemplate.suffix}`));
713
+ await session.onebot.sendGroupMsg(channelId, content);
714
+ }
715
+ function formatDate(date) {
716
+ return date.toLocaleDateString("zh-CN", {
717
+ year: "numeric",
718
+ month: "2-digit",
719
+ day: "2-digit"
825
720
  });
826
- try {
827
- const result = await ctx.database.create("echo_cave", {
828
- channelId,
829
- createTime: /* @__PURE__ */ new Date(),
830
- userId,
831
- originUserId: quote.user.id,
832
- type,
833
- content,
834
- relatedUsers: parsedUserIds || []
721
+ }
722
+
723
+ // src/core/command/get-cave.ts
724
+ async function getCaveListByUser(ctx, session) {
725
+ if (!session.guildId) {
726
+ return session.text("echo-cave.general.privateChatReminder");
727
+ }
728
+ const { userId, channelId } = session;
729
+ const caves = await ctx.database.get("echo_cave", {
730
+ userId,
731
+ channelId
732
+ });
733
+ if (caves.length === 0) {
734
+ return session.text(".noMsgContributed");
735
+ }
736
+ let response = session.text(".msgListHeader") + "\n";
737
+ for (const cave of caves) {
738
+ response += session.text(".msgListItem", [cave.id, formatDate(cave.createTime)]) + "\n";
739
+ }
740
+ return response;
741
+ }
742
+ async function getCaveListByOriginUser(ctx, session) {
743
+ if (!session.guildId) {
744
+ return session.text("echo-cave.general.privateChatReminder");
745
+ }
746
+ const { userId, channelId } = session;
747
+ const caves = await ctx.database.get("echo_cave", {
748
+ originUserId: userId,
749
+ channelId
750
+ });
751
+ if (caves.length === 0) {
752
+ return session.text(".noMsgTraced");
753
+ }
754
+ let response = session.text(".msgListHeader") + "\n";
755
+ for (const cave of caves) {
756
+ response += session.text(".msgListItem", [cave.id, formatDate(cave.createTime)]) + "\n";
757
+ }
758
+ return response;
759
+ }
760
+ async function getCave(ctx, session, cfg, id) {
761
+ if (!session.guildId) {
762
+ return session.text("echo-cave.general.privateChatReminder");
763
+ }
764
+ let caveMsg;
765
+ const { channelId } = session;
766
+ if (!id) {
767
+ const caves = await ctx.database.get("echo_cave", {
768
+ channelId
835
769
  });
836
- return session.text(".msgSaved", [result.id]);
837
- } catch (error) {
838
- return session.text(".msgFailedToSave");
770
+ if (caves.length === 0) {
771
+ return session.text(".noMsgInCave");
772
+ }
773
+ caveMsg = caves[Math.floor(Math.random() * caves.length)];
774
+ } else {
775
+ const caves = await ctx.database.get("echo_cave", {
776
+ id,
777
+ channelId
778
+ });
779
+ if (caves.length === 0) {
780
+ return session.text("echo-cave.general.noMsgWithId");
781
+ }
782
+ caveMsg = caves[0];
839
783
  }
784
+ await sendCaveMsg(ctx, session, caveMsg, cfg);
840
785
  }
786
+
787
+ // src/core/command/misc/bind-user.ts
841
788
  async function bindUsersToCave(ctx, session, id, userIds) {
842
789
  if (!session.guildId) {
843
790
  return session.text("echo-cave.general.privateChatReminder");
@@ -845,38 +792,43 @@ async function bindUsersToCave(ctx, session, id, userIds) {
845
792
  if (!id) {
846
793
  return session.text(".noIdProvided");
847
794
  }
848
- if (!userIds || userIds.length === 0) {
795
+ if (!userIds) {
849
796
  return session.text(".noUserIdProvided");
850
797
  }
851
- let parsedUserIds = [];
852
798
  const result = parseUserIds(userIds);
853
799
  if (result.error === "invalid_all_mention") {
854
- return session.text(".invalidAllMention");
800
+ return session.text("echo-cave.user.invalidAllMention");
801
+ }
802
+ const parsedUserIds = result.parsedUserIds;
803
+ if (parsedUserIds.length === 0) {
804
+ return session.text(".noValidUserIdProvided");
855
805
  }
856
- parsedUserIds = result.parsedUserIds;
857
806
  const caves = await ctx.database.get("echo_cave", id);
858
807
  if (caves.length === 0) {
859
808
  return session.text("echo-cave.general.noMsgWithId");
860
809
  }
861
810
  const isAllUsersInGroup = await checkUsersInGroup(ctx, session, parsedUserIds);
862
811
  if (!isAllUsersInGroup) {
863
- return session.text(".userNotInGroup");
812
+ return session.text("echo-cave.user.userNotInGroup");
864
813
  }
865
814
  await ctx.database.set("echo_cave", id, {
866
815
  relatedUsers: parsedUserIds
867
816
  });
868
817
  return session.text(".userBoundSuccess", [id]);
869
818
  }
819
+
820
+ // src/core/command/search-cave.ts
821
+ var import_koishi2 = require("koishi");
870
822
  async function searchCave(ctx, session, userIds) {
871
823
  if (!session.guildId) {
872
824
  return session.text("echo-cave.general.privateChatReminder");
873
825
  }
874
- if (!userIds || userIds.length === 0) {
826
+ if (!userIds) {
875
827
  return session.text(".noUserIdProvided");
876
828
  }
877
- const result = parseUserIds(userIds);
829
+ const result = parseUserIds(userIds.toString());
878
830
  if (result.error === "invalid_all_mention") {
879
- return session.text(".invalidAllMention");
831
+ return session.text("echo-cave.user.invalidAllMention");
880
832
  }
881
833
  const parsedUserIds = result.parsedUserIds;
882
834
  if (parsedUserIds.length === 0) {
@@ -884,15 +836,16 @@ async function searchCave(ctx, session, userIds) {
884
836
  }
885
837
  const isUserInGroup = await checkUsersInGroup(ctx, session, parsedUserIds);
886
838
  if (!isUserInGroup) {
887
- return session.text(".userNotInGroup");
839
+ return session.text("echo-cave.user.userNotInGroup");
888
840
  }
889
841
  const targetUserId = parsedUserIds[0];
890
842
  const { channelId } = session;
891
- const caves = await ctx.database.get("echo_cave", {
892
- channelId
893
- });
894
- const matchingCaves = caves.filter(
895
- (cave) => cave.originUserId === targetUserId || cave.relatedUsers.includes(targetUserId)
843
+ const matchingCaves = await ctx.database.get(
844
+ "echo_cave",
845
+ (row) => import_koishi2.$.and(
846
+ import_koishi2.$.eq(row.channelId, channelId),
847
+ import_koishi2.$.or(import_koishi2.$.eq(row.originUserId, targetUserId), import_koishi2.$.in(targetUserId, row.relatedUsers))
848
+ )
896
849
  );
897
850
  if (matchingCaves.length === 0) {
898
851
  return session.text(".noMatchingCaves", [targetUserId]);
@@ -901,9 +854,54 @@ async function searchCave(ctx, session, userIds) {
901
854
  const count = matchingCaves.length;
902
855
  return session.text(".searchResult", [count, caveIds]);
903
856
  }
857
+
858
+ // src/index.ts
859
+ var name = "echo-cave";
860
+ var inject = ["database"];
861
+ function apply(ctx, cfg) {
862
+ ctx.i18n.define("zh-CN", require_zh_CN());
863
+ ctx.model.extend(
864
+ "echo_cave",
865
+ {
866
+ id: "unsigned",
867
+ channelId: "string",
868
+ createTime: "timestamp",
869
+ userId: "string",
870
+ originUserId: "string",
871
+ type: "string",
872
+ content: "text",
873
+ relatedUsers: "list"
874
+ },
875
+ {
876
+ primary: "id",
877
+ autoInc: true
878
+ }
879
+ );
880
+ ctx.command("cave [id:number]").action(
881
+ async ({ session }, id) => await getCave(ctx, session, cfg, id)
882
+ );
883
+ ctx.command("cave.listen").action(async ({ session }) => await getCaveListByUser(ctx, session));
884
+ ctx.command("cave.trace").action(
885
+ async ({ session }) => await getCaveListByOriginUser(ctx, session)
886
+ );
887
+ ctx.command("cave.echo [...userIds]").action(
888
+ async ({ session }, ...userIds) => await addCave(ctx, session, cfg, userIds)
889
+ );
890
+ ctx.command("cave.drop <id:number>").action(
891
+ async ({ session }, id) => await deleteCave(ctx, session, cfg, id)
892
+ );
893
+ ctx.command("cave.purge <...ids:number>").action(
894
+ async ({ session }, ...ids) => await deleteCaves(ctx, session, cfg, ids)
895
+ );
896
+ ctx.command("cave.search <id:number>").action(
897
+ async ({ session }, id) => await searchCave(ctx, session, id)
898
+ );
899
+ ctx.command("cave.bind <id:number> <...userIds>", { authority: 4 }).action(
900
+ async ({ session }, id, ...userIds) => await bindUsersToCave(ctx, session, id, userIds)
901
+ );
902
+ }
904
903
  // Annotate the CommonJS export names for ESM import in node:
905
904
  0 && (module.exports = {
906
- Config,
907
905
  apply,
908
906
  inject,
909
907
  name
package/lib/index.d.ts CHANGED
@@ -1,20 +1,8 @@
1
1
  import '@pynickle/koishi-plugin-adapter-onebot';
2
- import { Context, Schema } from 'koishi';
2
+ import { Config } from './config/config';
3
+ import { Context } from 'koishi';
3
4
  export declare const name = "echo-cave";
4
5
  export declare const inject: string[];
5
- export interface Config {
6
- adminMessageProtection?: boolean;
7
- allowContributorDelete?: boolean;
8
- allowSenderDelete?: boolean;
9
- deleteMediaWhenDeletingMsg?: boolean;
10
- enableSizeLimit?: boolean;
11
- maxImageSize?: number;
12
- maxVideoSize?: number;
13
- maxFileSize?: number;
14
- maxRecordSize?: number;
15
- useBase64ForMedia?: boolean;
16
- }
17
- export declare const Config: Schema<Config>;
18
6
  export interface EchoCave {
19
7
  id: number;
20
8
  channelId: string;
@@ -1,4 +1,4 @@
1
- import { Config } from './index';
1
+ import { Config } from '../../config/config';
2
2
  import { Context } from 'koishi';
3
3
  export declare function saveMedia(ctx: Context, mediaElement: Record<string, any>, type: 'image' | 'video' | 'file' | 'record', cfg: Config): Promise<string>;
4
4
  export declare function processMediaElement(ctx: Context, element: any, cfg: Config): Promise<any>;
@@ -0,0 +1,6 @@
1
+ export declare function createTextMsg(content: string): {
2
+ type: string;
3
+ data: {
4
+ text: string;
5
+ };
6
+ };
@@ -0,0 +1,5 @@
1
+ export interface ParseResult {
2
+ parsedUserIds: string[];
3
+ error?: string;
4
+ }
5
+ export declare function parseUserIds(userIds: string[] | string): ParseResult;
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.17.0",
4
+ "version": "1.18.1",
5
5
  "main": "lib/index.cjs",
6
6
  "typings": "lib/index.d.ts",
7
7
  "type": "module",
@@ -1,11 +0,0 @@
1
- export interface ParseResult {
2
- parsedUserIds: string[];
3
- error?: string;
4
- }
5
- export declare function createTextMsg(content: string): {
6
- type: string;
7
- data: {
8
- text: string;
9
- };
10
- };
11
- export declare function parseUserIds(userIds: any[]): ParseResult;