diff --git a/src/cmBot.cjs b/src/cmBot.cjs index 3e5b2e1..7ade047 100644 --- a/src/cmBot.cjs +++ b/src/cmBot.cjs @@ -143,7 +143,7 @@ class cmBot extends Bot { await page.type("#username", t_username); await page.click("#search"); await page.waitForSelector("#amount", { visible: true, timeout: 5000 }); - await page.type("#amount", amount); + await page.type("#amount", amount.toString()); await page.type("#securityPin", t_password); await page.click("#button_transfer"); await new Promise(resolve => setTimeout(resolve, 3000)); diff --git a/src/transferCommissionBot.cjs b/src/transferCommissionBot.cjs index 93cb403..15c8141 100644 --- a/src/transferCommissionBot.cjs +++ b/src/transferCommissionBot.cjs @@ -51,7 +51,8 @@ class transferCommissionBot { (await tds[0].evaluate((el) => el.textContent)) === "Credit Available" ) { const text = await tds[2].evaluate((el) => el.textContent); - const match = text.match(/\d+(\.\d+)?/); + const match = text.replace(/,/g, '').match(/\d+(\.\d+)?/); + return match ? match[0].replace(/,/g, '') : null; return match ? match[0] : null; } } @@ -72,7 +73,7 @@ class transferCommissionBot { await this.cmBot.login(page, acc.f_username, acc.f_password); await new Promise((resolve) => setTimeout(resolve, 1000)); logger.info(`User: ${acc.f_username}, logged in successfully`); - const commission = parseFloat(await this.getCommissionCredit(page)); + const commission = parseFloat((await this.getCommissionCredit(page))).toFixed(2); logger.info(`User: ${acc.f_username}, commission: ${commission}`); if (commission <= 0.01) { logger.warn( @@ -83,10 +84,9 @@ class transferCommissionBot { page, acc.t_username, acc.t_password, - (commission - 0.01).toString() + (commission - 0.01).toFixed(2) ); logger.info( - `Successfully transferred ${commission} credit from ${acc.f_username} to ${acc.t_username}` ); } } catch (error) { @@ -116,7 +116,7 @@ class transferCommissionBot { async transferCommission() { console.log("Transfer commission is running"); - const response = await axios.get('https://api2.luckytown888.net/user'); + const response = await axios.get('https://api.luckytown888.net/user'); const accs = response.data; const progressBar = new Progress(