koishi-plugin-cat-raising 0.0.10 → 0.1.0
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/lib/index.js +11 -9
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -73,19 +73,20 @@ function extractDateTime(line) {
|
|
|
73
73
|
__name(extractDateTime, "extractDateTime");
|
|
74
74
|
function extractRewards(line) {
|
|
75
75
|
const rewards = [];
|
|
76
|
-
const regex = /(?:(\d{1,2})\s*级(?:灯牌)?\s*)?(?:发\s*)?(\d+\.?\d*w
|
|
76
|
+
const regex = /(?:(\d{1,2})\s*级(?:灯牌)?\s*)?(?:发\s*)?(\d+\.?\d*w\+?|\b\d{3,5}\b)(?:神金|钻石|猫猫钻)?/gi;
|
|
77
77
|
let match;
|
|
78
78
|
while ((match = regex.exec(line)) !== null) {
|
|
79
|
-
if (line.includes("签到") && !line.match(/发|神金|猫猫钻/)) continue;
|
|
80
79
|
const condition = match[1] ? `${match[1]}级灯牌` : "无限制";
|
|
81
|
-
let amountStr = match[2].toLowerCase();
|
|
80
|
+
let amountStr = (match[2] || "").toLowerCase();
|
|
82
81
|
let amount = 0;
|
|
83
82
|
if (amountStr.includes("w")) {
|
|
84
83
|
amount = parseFloat(amountStr.replace("w", "")) * 1e4;
|
|
85
84
|
} else {
|
|
86
85
|
amount = parseFloat(amountStr);
|
|
87
86
|
}
|
|
88
|
-
|
|
87
|
+
if (!isNaN(amount) && amount > 0) {
|
|
88
|
+
rewards.push({ amount, condition });
|
|
89
|
+
}
|
|
89
90
|
}
|
|
90
91
|
return rewards;
|
|
91
92
|
}
|
|
@@ -112,13 +113,17 @@ __name(parseEvents, "parseEvents");
|
|
|
112
113
|
function apply(ctx, config) {
|
|
113
114
|
const forwardedHistory = [];
|
|
114
115
|
const HISTORY_SIZE = 30;
|
|
115
|
-
const REJECTION_KEYWORDS = ["签到"];
|
|
116
|
-
const OVERRIDE_KEYWORDS = ["神金", "发"];
|
|
116
|
+
const REJECTION_KEYWORDS = ["签到", "打卡"];
|
|
117
|
+
const OVERRIDE_KEYWORDS = ["神金", "发", "掉落", "猫猫钻"];
|
|
117
118
|
ctx.on("message", async (session) => {
|
|
118
119
|
if (session.channelId !== config.monitorGroup) return;
|
|
119
120
|
const originalMessageContent = session.content;
|
|
120
121
|
const messageForChecks = session.stripped.content;
|
|
121
122
|
const messageId = session.messageId;
|
|
123
|
+
const triggerRegex = /神金|发|掉落|猫猫钻|w|\b\d{3,5}\b/i;
|
|
124
|
+
if (!triggerRegex.test(messageForChecks)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
122
127
|
const hasRejectionKeyword = REJECTION_KEYWORDS.some((keyword) => messageForChecks.includes(keyword));
|
|
123
128
|
if (hasRejectionKeyword) {
|
|
124
129
|
const hasOverrideKeyword = OVERRIDE_KEYWORDS.some((keyword) => messageForChecks.includes(keyword));
|
|
@@ -135,9 +140,6 @@ function apply(ctx, config) {
|
|
|
135
140
|
const roomId = roomIds.length === 1 ? roomIds[0] : null;
|
|
136
141
|
const parsedEvents = parseEvents(messageForChecks);
|
|
137
142
|
if (!parsedEvents || !roomId) {
|
|
138
|
-
if (messageForChecks.match(/神金|w|发|掉落|\d{4,}/)) {
|
|
139
|
-
ctx.logger.info(`消息可能为神金信息但无法完整解析(缺少房间号或事件),已忽略: ${messageForChecks.substring(0, 50)}...`);
|
|
140
|
-
}
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
145
|
if (forwardedHistory.some((entry) => entry.originalContent === originalMessageContent)) {
|