koishi-plugin-cat-raising 0.1.6 → 0.1.7

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.
Files changed (2) hide show
  1. package/lib/index.js +15 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -31,7 +31,6 @@ var Config = import_koishi.Schema.object({
31
31
  targetQQ: import_koishi.Schema.string().description("目标QQ号或QQ群号").required(),
32
32
  isGroup: import_koishi.Schema.boolean().description("是否为QQ群").default(false),
33
33
  monitorGroup: import_koishi.Schema.string().description("监听的群号(只检测此群的消息)").required(),
34
- // [核心改动 2] 添加配置项的UI描述
35
34
  historySize: import_koishi.Schema.number().description("防复读历史记录大小 (记录最近N条转发信息,防止短期内对同一直播间的同一活动重复转发)").default(30).min(5).max(100)
36
35
  });
37
36
  function extractAllRoomIds(text) {
@@ -170,6 +169,7 @@ function apply(ctx, config) {
170
169
  return;
171
170
  }
172
171
  let biliInfo = "";
172
+ let helperMessageId = void 0;
173
173
  try {
174
174
  const roomInfoUrl = `https://api.live.bilibili.com/room/v1/Room/get_info?room_id=${roomId}`;
175
175
  const roomInfo = await ctx.http.get(roomInfoUrl);
@@ -184,8 +184,11 @@ function apply(ctx, config) {
184
184
  ---
185
185
  用户投稿数: ${videoCount}`;
186
186
  try {
187
- await session.send(`直播间: ${roomId}
187
+ const sentMessageIds = await session.send(`直播间: ${roomId}
188
188
  用户投稿数: ${videoCount}`);
189
+ if (sentMessageIds && sentMessageIds.length > 0) {
190
+ helperMessageId = sentMessageIds[0];
191
+ }
189
192
  } catch (e) {
190
193
  ctx.logger.warn(`向监听群 ${config.monitorGroup} 发送B站信息时失败:`, e);
191
194
  }
@@ -206,6 +209,8 @@ function apply(ctx, config) {
206
209
  const newEntry = {
207
210
  originalMessageId: messageId,
208
211
  forwardedMessageId,
212
+ helperMessageId,
213
+ // [核心改动 4] 存入历史记录
209
214
  originalContent: originalMessageContent,
210
215
  roomId,
211
216
  dateTime: currentDateTime
@@ -224,6 +229,14 @@ function apply(ctx, config) {
224
229
  const entryIndex = forwardedHistory.findIndex((entry) => entry.originalMessageId === originalMessageId);
225
230
  if (entryIndex !== -1) {
226
231
  const entry = forwardedHistory[entryIndex];
232
+ if (entry.helperMessageId) {
233
+ try {
234
+ await session.bot.deleteMessage(session.channelId, entry.helperMessageId);
235
+ ctx.logger.info(`成功撤回监听群内的助手消息: ${entry.helperMessageId}`);
236
+ } catch (error) {
237
+ ctx.logger.error(`撤回助手消息 (ID: ${entry.helperMessageId}) 失败:`, error);
238
+ }
239
+ }
227
240
  try {
228
241
  await session.bot.deleteMessage(config.targetQQ, entry.forwardedMessageId);
229
242
  ctx.logger.info(`成功撤回转发的消息: ${entry.forwardedMessageId}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-cat-raising",
3
3
  "description": "",
4
- "version": "0.1.6",
4
+ "version": "0.1.7",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [