@@ -2,15 +2,15 @@ import {
2
2
idAutoBuyerFoundLog ,
3
3
idProgressAutobuyer
4
4
} from "../elementIds.constants" ;
5
- import { startAutoBuyer , stopAutoBuyer } from "../handlers/autobuyerProcessor" ;
5
+ import { autoRestartAutoBuyer , startAutoBuyer , stopAutoBuyer } from "../handlers/autobuyerProcessor" ;
6
6
import { updateStats } from "../handlers/statsProcessor" ;
7
7
import {
8
8
getValue ,
9
9
increAndGetStoreValue ,
10
10
setValue
11
11
} from "../services/repository" ;
12
12
import {
13
- convertRangeToSeconds ,
13
+ convertRangeToSeconds , convertSecondsToTime ,
14
14
getRandNum ,
15
15
getRandNumberInRange ,
16
16
hideLoader ,
@@ -38,27 +38,41 @@ export const stopBotIfRequired = (buyerSetting) => {
38
38
const isSelling = false ;
39
39
// buyerSetting["idSellCheckBuyPrice"] || buyerSetting["idSellFutBinPrice"];
40
40
const isTransferListFull =
41
- isSelling &&
42
- repositories . Item &&
43
- repositories . Item . transfer . length >=
41
+ isSelling &&
42
+ repositories . Item &&
43
+ repositories . Item . transfer . length >=
44
44
repositories . Item . pileSizes . _collection [ 5 ] ;
45
45
46
- if (
47
- isTransferListFull ||
48
- timeElapsed ||
49
- ( cardsToBuy && purchasedCardCount >= cardsToBuy )
50
- ) {
51
- const message = timeElapsed
46
+ const message = timeElapsed
52
47
? "Time elapsed"
53
48
: isTransferListFull
54
- ? "Transfer list is full"
55
- : "Max purchases count reached" ;
49
+ ? "Transfer list is full"
50
+ : "Max purchases count reached" ;
56
51
57
- if ( sendDetailedNotification )
58
- sendNotificationToUser ( `Autobuyer stopped | ${ message } ` ) ;
59
- writeToLog ( `Autobuyer stopped | ${ message } ` , idProgressAutobuyer ) ;
52
+ if ( timeElapsed ) {
53
+ if ( buyerSetting [ "idAbRestartAfter" ] ) {
54
+ const autoRestart = convertRangeToSeconds (
55
+ buyerSetting [ "idAbRestartAfter" ]
56
+ ) ;
57
+ writeToLog (
58
+ `Autobuyer stopped (Time elapsed) | Automatic restart in ${ convertSecondsToTime ( autoRestart ) } ` ,
59
+ idProgressAutobuyer
60
+ ) ;
61
+
62
+ }
60
63
stopAfter = null ;
61
- stopAutoBuyer ( ) ;
64
+
65
+ stopAutoBuyer ( false ) ;
66
+ autoRestartAutoBuyer ( ) ;
67
+ } else {
68
+ if ( isTransferListFull || ( cardsToBuy && purchasedCardCount >= cardsToBuy ) ) {
69
+
70
+ if ( sendDetailedNotification )
71
+ sendNotificationToUser ( `Autobuyer stopped | ${ message } ` ) ;
72
+ writeToLog ( `Autobuyer stopped | ${ message } ` , idProgressAutobuyer ) ;
73
+ stopAfter = null ;
74
+ stopAutoBuyer ( ) ;
75
+ }
62
76
}
63
77
} ;
64
78
@@ -67,7 +81,7 @@ export const pauseBotIfRequired = async function (buyerSetting) {
67
81
if ( ! isBuyerActive ) return ;
68
82
const pauseFor = convertRangeToSeconds ( buyerSetting [ "idAbPauseFor" ] ) * 1000 ;
69
83
const cycleAmount =
70
- pauseCycle || getRandNumberInRange ( buyerSetting [ "idAbCycleAmount" ] ) ;
84
+ pauseCycle || getRandNumberInRange ( buyerSetting [ "idAbCycleAmount" ] ) ;
71
85
if ( ! pauseCycle ) {
72
86
pauseCycle = cycleAmount ;
73
87
}
@@ -103,9 +117,9 @@ export const switchFilterIfRequired = async function () {
103
117
const fiterSearchCount = getValue ( "fiterSearchCount" ) ;
104
118
const currentFilterCount = getValue ( "currentFilterCount" ) ;
105
119
if (
106
- ! availableFilters ||
107
- ! availableFilters . length ||
108
- fiterSearchCount > currentFilterCount
120
+ ! availableFilters ||
121
+ ! availableFilters . length ||
122
+ fiterSearchCount > currentFilterCount
109
123
) {
110
124
increAndGetStoreValue ( "currentFilterCount" ) ;
111
125
return false ;
@@ -114,14 +128,14 @@ export const switchFilterIfRequired = async function () {
114
128
setValue ( "currentPage" , 1 ) ;
115
129
const currentFilterIndex = getValue ( "currentFilterIndex" ) || 0 ;
116
130
let filterIndex = getValue ( "runSequentially" )
117
- ? currentFilterIndex % availableFilters . length
118
- : getRandNum ( 0 , availableFilters . length - 1 ) ;
131
+ ? currentFilterIndex % availableFilters . length
132
+ : getRandNum ( 0 , availableFilters . length - 1 ) ;
119
133
120
134
setValue ( "currentFilterIndex" , filterIndex + 1 ) ;
121
135
let filterName = availableFilters [ filterIndex ] ;
122
136
await loadFilter . call ( this , filterName ) ;
123
137
writeToLog (
124
- `--------------------------- Running for filter ${ filterName } ---------------------------------------------` ,
125
- idAutoBuyerFoundLog
138
+ `--------------------------- Running for filter ${ filterName } ---------------------------------------------` ,
139
+ idAutoBuyerFoundLog
126
140
) ;
127
141
} ;
0 commit comments