dankgrinder 4.9.0 → 4.9.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/lib/commands/generic.js +2 -0
- package/lib/grinder.js +24 -12
- package/package.json +1 -1
package/lib/commands/generic.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
const {
|
|
8
8
|
LOG, c, getFullText, parseCoins, getAllButtons, getAllSelectMenus,
|
|
9
9
|
safeClickButton, logMsg, isHoldTight, getHoldTightReason, sleep, humanDelay, needsItem,
|
|
10
|
+
isCV2, ensureCV2,
|
|
10
11
|
} = require('./utils');
|
|
11
12
|
const { buyItem } = require('./shop');
|
|
12
13
|
|
|
@@ -37,6 +38,7 @@ async function runGeneric({ channel, waitForDankMemer, cmdString, cmdName, clien
|
|
|
37
38
|
return { result: `hold tight (${reason || 'unknown'})`, coins: 0, holdTightReason: reason };
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
if (isCV2(response)) await ensureCV2(response);
|
|
40
42
|
logMsg(response, cmdName);
|
|
41
43
|
const text = getFullText(response);
|
|
42
44
|
const coins = parseCoins(text);
|
package/lib/grinder.js
CHANGED
|
@@ -791,6 +791,10 @@ class AccountWorker {
|
|
|
791
791
|
|
|
792
792
|
// ── Check Balance ───────────────────────────────────────────
|
|
793
793
|
async checkInventory() {
|
|
794
|
+
if (this._invRunning) return;
|
|
795
|
+
if (this._lastInvCheck && Date.now() - this._lastInvCheck < 300_000) return;
|
|
796
|
+
this._invRunning = true;
|
|
797
|
+
this._lastInvCheck = Date.now();
|
|
794
798
|
try {
|
|
795
799
|
this.log('info', 'Checking inventory...');
|
|
796
800
|
const result = await commands.runInventory({
|
|
@@ -817,6 +821,8 @@ class AccountWorker {
|
|
|
817
821
|
}
|
|
818
822
|
} catch (e) {
|
|
819
823
|
this.log('error', `Inventory check failed: ${e.message}`);
|
|
824
|
+
} finally {
|
|
825
|
+
this._invRunning = false;
|
|
820
826
|
}
|
|
821
827
|
}
|
|
822
828
|
|
|
@@ -881,16 +887,17 @@ class AccountWorker {
|
|
|
881
887
|
// handles Hold Tight / cooldowns / item-buying internally.
|
|
882
888
|
async runCommand(cmdName, prefix) {
|
|
883
889
|
let cmdString;
|
|
884
|
-
const
|
|
890
|
+
const bjBet = Math.max(5000, this.account.bet_amount || 5000);
|
|
891
|
+
const gambBet = Math.max(10000, this.account.bet_amount || 10000);
|
|
885
892
|
|
|
886
893
|
switch (cmdName) {
|
|
887
894
|
case 'dep max': cmdString = `${prefix} dep max`; break;
|
|
888
895
|
case 'with max': cmdString = `${prefix} with max`; break;
|
|
889
|
-
case 'blackjack': cmdString = `${prefix} bj ${
|
|
890
|
-
case 'cointoss': cmdString = `${prefix} cointoss ${
|
|
891
|
-
case 'roulette': cmdString = `${prefix} roulette ${
|
|
892
|
-
case 'slots': cmdString = `${prefix} slots ${
|
|
893
|
-
case 'snakeeyes': cmdString = `${prefix} snakeeyes ${
|
|
896
|
+
case 'blackjack': cmdString = `${prefix} bj ${bjBet}`; break;
|
|
897
|
+
case 'cointoss': cmdString = `${prefix} cointoss ${gambBet}`; break;
|
|
898
|
+
case 'roulette': cmdString = `${prefix} roulette ${gambBet} red`; break;
|
|
899
|
+
case 'slots': cmdString = `${prefix} slots ${gambBet}`; break;
|
|
900
|
+
case 'snakeeyes': cmdString = `${prefix} snakeeyes ${gambBet}`; break;
|
|
894
901
|
case 'work shift': cmdString = `${prefix} work shift`; break;
|
|
895
902
|
case 'weekly': cmdString = `${prefix} weekly`; break;
|
|
896
903
|
case 'monthly': cmdString = `${prefix} monthly`; break;
|
|
@@ -906,7 +913,7 @@ class AccountWorker {
|
|
|
906
913
|
client: this.client,
|
|
907
914
|
safeAnswers: cmdName === 'search' ? safeParseJSON(this.account.search_answers, []) :
|
|
908
915
|
cmdName === 'crime' ? safeParseJSON(this.account.crime_answers, []) : [],
|
|
909
|
-
betAmount,
|
|
916
|
+
betAmount: ['blackjack'].includes(cmdName) ? bjBet : gambBet,
|
|
910
917
|
accountId: this.account.id,
|
|
911
918
|
redis,
|
|
912
919
|
};
|
|
@@ -1042,7 +1049,10 @@ class AccountWorker {
|
|
|
1042
1049
|
const earned = Math.max(0, cmdResult.coins || 0);
|
|
1043
1050
|
const spent = Math.max(0, cmdResult.lost || 0);
|
|
1044
1051
|
if (earned > 0) this.stats.coins += earned;
|
|
1045
|
-
if (cmdResult.nextCooldownSec)
|
|
1052
|
+
if (cmdResult.nextCooldownSec) {
|
|
1053
|
+
await this.setCooldown(cmdName, cmdResult.nextCooldownSec);
|
|
1054
|
+
this._lastCooldownOverride = cmdResult.nextCooldownSec;
|
|
1055
|
+
}
|
|
1046
1056
|
|
|
1047
1057
|
// Mark time-gated commands as done so we don't re-run this session
|
|
1048
1058
|
const doneExpiries = { daily: 86400, weekly: 604800, monthly: 2592000, drops: 86400 };
|
|
@@ -1065,12 +1075,12 @@ class AccountWorker {
|
|
|
1065
1075
|
this.stats.successes++;
|
|
1066
1076
|
const shortResult = result.substring(0, 30).replace(/\n/g, ' ');
|
|
1067
1077
|
this.setStatus(`${cmdName} → ${shortResult}`);
|
|
1068
|
-
await sendLog(this.username,
|
|
1078
|
+
await sendLog(this.username, cmdName, result, 'success');
|
|
1069
1079
|
reportEarnings(this.account.id, this.username, earned, spent, cmdName);
|
|
1070
1080
|
} catch (err) {
|
|
1071
1081
|
this.stats.errors++;
|
|
1072
1082
|
this.log('error', `${cmdString} failed: ${err.message}`);
|
|
1073
|
-
await sendLog(this.username,
|
|
1083
|
+
await sendLog(this.username, cmdName, err.message, 'error');
|
|
1074
1084
|
}
|
|
1075
1085
|
}
|
|
1076
1086
|
|
|
@@ -1351,7 +1361,9 @@ class AccountWorker {
|
|
|
1351
1361
|
const backoffMultiplier = this.failStreak > 5 ? Math.min(this.failStreak - 4, 5) : 1;
|
|
1352
1362
|
|
|
1353
1363
|
if (this.commandQueue && this.running && !shutdownCalled) {
|
|
1354
|
-
|
|
1364
|
+
const effectiveWait = this._lastCooldownOverride || totalWait;
|
|
1365
|
+
this._lastCooldownOverride = null;
|
|
1366
|
+
item.nextRunAt = Date.now() + effectiveWait * 1000 * backoffMultiplier;
|
|
1355
1367
|
this.commandQueue.push(item);
|
|
1356
1368
|
}
|
|
1357
1369
|
|
|
@@ -1371,7 +1383,7 @@ class AccountWorker {
|
|
|
1371
1383
|
this.cycleCount++;
|
|
1372
1384
|
|
|
1373
1385
|
if (this.cycleCount > 0 && this.cycleCount % 10 === 0) this.printStats();
|
|
1374
|
-
if (this.cycleCount > 0 && this.cycleCount %
|
|
1386
|
+
if (this.cycleCount > 0 && this.cycleCount % 5 === 0) {
|
|
1375
1387
|
this.busy = true;
|
|
1376
1388
|
await this.checkBalance();
|
|
1377
1389
|
this.busy = false;
|