koishi-plugin-cat-raising 0.1.0 → 0.1.2

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 +13 -4
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -134,7 +134,6 @@ function apply(ctx, config) {
134
134
  }
135
135
  const roomIds = extractAllRoomIds(messageForChecks);
136
136
  if (roomIds.length > 1) {
137
- session.send(`检测到多个直播间号 (${roomIds.join(", ")}),为避免信息混淆,已停止处理。`);
138
137
  return;
139
138
  }
140
139
  const roomId = roomIds.length === 1 ? roomIds[0] : null;
@@ -142,8 +141,15 @@ function apply(ctx, config) {
142
141
  if (!parsedEvents || !roomId) {
143
142
  return;
144
143
  }
145
- if (forwardedHistory.some((entry) => entry.originalContent === originalMessageContent)) {
146
- session.send("这个消息刚刚已经发过啦~");
144
+ const strongContextRegex = /神金|发|掉落|猫猫钻|w/i;
145
+ const hasStrongContext = strongContextRegex.test(messageForChecks);
146
+ const hasTime = parsedEvents.some((event) => event.dateTime !== "时间未知");
147
+ if (!hasStrongContext && !hasTime) {
148
+ ctx.logger.info(`纯数字信息缺少时间,已忽略: ${messageForChecks.replace(/\s+/g, " ").substring(0, 50)}...`);
149
+ return;
150
+ }
151
+ if (forwardedHistory.some((entry) => entry.roomId === roomId)) {
152
+ session.send(`看到啦看到啦,不要发那么多次嘛~`);
147
153
  return;
148
154
  }
149
155
  let biliInfo = "";
@@ -168,6 +174,7 @@ function apply(ctx, config) {
168
174
  }
169
175
  } catch (error) {
170
176
  ctx.logger.warn(`获取直播间 ${roomId} 的B站信息失败: ${error.message}`);
177
+ return;
171
178
  }
172
179
  const forwardMessage = originalMessageContent + biliInfo;
173
180
  try {
@@ -182,7 +189,9 @@ function apply(ctx, config) {
182
189
  const newEntry = {
183
190
  originalMessageId: messageId,
184
191
  forwardedMessageId,
185
- originalContent: originalMessageContent
192
+ originalContent: originalMessageContent,
193
+ roomId
194
+ // 新增
186
195
  };
187
196
  forwardedHistory.push(newEntry);
188
197
  if (forwardedHistory.length > HISTORY_SIZE) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-cat-raising",
3
3
  "description": "",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [