dankgrinder 5.9.0 → 5.10.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/commands/dig.js +1 -1
- package/lib/commands/hunt.js +1 -1
- package/lib/commands/shop.js +11 -3
- package/lib/commands/utils.js +8 -2
- package/package.json +1 -1
package/lib/commands/dig.js
CHANGED
|
@@ -42,7 +42,7 @@ async function runDig({ channel, waitForDankMemer, client }) {
|
|
|
42
42
|
const missing = needsItem(cleanText);
|
|
43
43
|
|
|
44
44
|
const shovelMissing = missing === 'shovel'
|
|
45
|
-
|| /(?:don't have|do not have|need|needs|requires?|missing|must have|you need|lack)\s+(?:a\s+)?shovel/.test(textLower)
|
|
45
|
+
|| /(?:don['’]?t have|do not have|need|needs|requires?|missing|must have|you need|lack)\s+(?:a\s+)?shovel/.test(textLower)
|
|
46
46
|
|| (textLower.includes('following items') && textLower.includes('shovel'));
|
|
47
47
|
|
|
48
48
|
// Check if we need a shovel
|
package/lib/commands/hunt.js
CHANGED
|
@@ -42,7 +42,7 @@ async function runHunt({ channel, waitForDankMemer, client }) {
|
|
|
42
42
|
const missing = needsItem(cleanText);
|
|
43
43
|
|
|
44
44
|
const rifleMissing = missing === 'hunting rifle'
|
|
45
|
-
|| /(?:don't have|do not have|need|needs|requires?|missing|must have|you need|lack)\s+(?:a\s+)?(?:hunting\s+)?rifle/.test(textLower)
|
|
45
|
+
|| /(?:don['’]?t have|do not have|need|needs|requires?|missing|must have|you need|lack)\s+(?:a\s+)?(?:hunting\s+)?rifle/.test(textLower)
|
|
46
46
|
|| ((textLower.includes('following items') || textLower.includes('missing items')) && textLower.includes('rifle'));
|
|
47
47
|
|
|
48
48
|
// Check if we need a rifle
|
package/lib/commands/shop.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
const {
|
|
17
17
|
LOG, c, sleep, humanDelay, getFullText,
|
|
18
18
|
getAllButtons, findSelectMenuOption,
|
|
19
|
-
logMsg, isHoldTight,
|
|
19
|
+
logMsg, isHoldTight, isCV2, ensureCV2,
|
|
20
20
|
} = require('./utils');
|
|
21
21
|
const { LRUCache, Trie } = require('../structures');
|
|
22
22
|
|
|
@@ -100,6 +100,8 @@ async function buyItem({ channel, waitForDankMemer, itemName, quantity = 1, clie
|
|
|
100
100
|
return false;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
if (isCV2(response)) await ensureCV2(response);
|
|
104
|
+
|
|
103
105
|
logMsg(response, 'shop');
|
|
104
106
|
|
|
105
107
|
// Step 2: Switch shop tab if needed (e.g. Fishing Shop for fishing pole)
|
|
@@ -129,6 +131,7 @@ async function buyItem({ channel, waitForDankMemer, itemName, quantity = 1, clie
|
|
|
129
131
|
);
|
|
130
132
|
if (result) {
|
|
131
133
|
response = result;
|
|
134
|
+
if (isCV2(response)) await ensureCV2(response);
|
|
132
135
|
LOG.success(`Switched to ${targetTab}`);
|
|
133
136
|
}
|
|
134
137
|
await sleep(300);
|
|
@@ -141,9 +144,14 @@ async function buyItem({ channel, waitForDankMemer, itemName, quantity = 1, clie
|
|
|
141
144
|
|
|
142
145
|
// Step 3: Find the Buy button for our item
|
|
143
146
|
const allBtns = getAllButtons(response);
|
|
147
|
+
const normalizedSearch = String(searchTerm || '').toLowerCase().replace(/\s+/g, '');
|
|
148
|
+
const normalizedKey = String(key || '').toLowerCase().replace(/\s+/g, '');
|
|
144
149
|
const buyBtn = allBtns.find(b => {
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
const label = String(b.label || '').toLowerCase();
|
|
151
|
+
const id = String(b.customId || b.custom_id || '').toLowerCase().replace(/\s+/g, '');
|
|
152
|
+
return label.includes(searchTerm)
|
|
153
|
+
|| (normalizedSearch && id.includes(normalizedSearch))
|
|
154
|
+
|| (normalizedKey && id.includes(normalizedKey));
|
|
147
155
|
});
|
|
148
156
|
|
|
149
157
|
if (!buyBtn) {
|
package/lib/commands/utils.js
CHANGED
|
@@ -529,10 +529,16 @@ itemDetector.addPattern('missing items', '__multi__');
|
|
|
529
529
|
itemDetector.build();
|
|
530
530
|
|
|
531
531
|
function needsItem(text) {
|
|
532
|
-
const
|
|
532
|
+
const normalized = String(text || '')
|
|
533
|
+
.toLowerCase()
|
|
534
|
+
.normalize('NFKC')
|
|
535
|
+
.replace(/[’‘`´]/g, "'")
|
|
536
|
+
.replace(/\bdon'?t\b/g, "don't");
|
|
537
|
+
|
|
538
|
+
const match = itemDetector.hasAny(normalized);
|
|
533
539
|
if (!match) return null;
|
|
534
540
|
if (match === '__multi__') {
|
|
535
|
-
const lower =
|
|
541
|
+
const lower = normalized;
|
|
536
542
|
if (lower.includes('shovel')) return 'shovel';
|
|
537
543
|
if (lower.includes('fishing pole') || lower.includes('fishing')) return 'fishing pole';
|
|
538
544
|
if (lower.includes('hunting rifle') || lower.includes('rifle')) return 'hunting rifle';
|