diff --git a/automatization.ts b/automatization.ts index 3da3c35..81a1ef3 100644 --- a/automatization.ts +++ b/automatization.ts @@ -7,6 +7,7 @@ import logger from "./logger"; import { waitNewMessages } from "./utils"; import {database as db,settings} from './database' import BigInteger from "big-integer"; +import { isNull } from "lodash"; export const vertification=async function (client: telegram.TelegramClient,worker: AccountInterface,hero: Hero,url: string,botEntity: telegram.Api.Chat | telegram.Api.User,idOfLastMessage: number) { @@ -48,18 +49,28 @@ export const doSitesTasks=async function (client: telegram.TelegramClient,worker }))[0]; if (task.buttonCount==2){ - if (prevTask.task.message==task.message){ - logger.warn(`Same tasks detected on ${worker.phoneNumber}...`); - } + logger.debug(`New ad task | ${worker.phoneNumber}`); - prevTask.task=task; + const urlButton=task.buttons![0][0]; const skipButton=task.buttons![0][1]; await hero.goto(urlButton.url!.replace("https","http"),{timeoutMs:180_000}); await hero.waitForLoad('AllContentLoaded',{timeoutMs:180_000}); - + let captchaButton=hero.document.querySelector('button.g-recaptcha.btn.btn-primary'); - if (captchaButton!=null && urlButton.url!.includes('hkbots')==true){ + if (isNull(captchaButton)){ + if (prevTask.task.message==task.message){ + logger.warn(`Same tasks detected on ${worker.phoneNumber}... Skipping due captcha isnt detected......`); + await skipButton.click({sharePhone: false}); + } else { + prevTask.task=task; + logger.warn(`Captcha isnt detected... | ${worker.phoneNumber}`); + } + + continue mainLoop; + } + prevTask.task=task; + if (urlButton.url!.includes('hkbots')==true){ if (await captchaButton.$isClickable!=true){ // timer page logger.warn(`Found timer... | ${worker.phoneNumber}`) @@ -78,7 +89,7 @@ export const doSitesTasks=async function (client: telegram.TelegramClient,worker } - while (captchaButton!=null && await hero.activeTab.url==urlButton.url!){ + while (await hero.activeTab.url==urlButton.url!){ const isCaptchaPassed=hero.document.querySelector("input[id='recaptcha-token']"); if ((isCaptchaPassed==null || await isCaptchaPassed.$isVisible==false) ){ if (await captchaButton.$isClickable){ @@ -143,11 +154,9 @@ export const doChatsTasks=async function (client: telegram.TelegramClient,worker // search: (await settings.botMessages()).tasksSelector, }))[0]; if (task.buttonCount==3){ - if (prevTask.task.message==task.message){ - logger.warn(`Same tasks detected on ${worker.phoneNumber}...`); - } + logger.info(`New chat task | ${worker.phoneNumber}`); - prevTask.task=task; + const urlButton=task.buttons![0][0]; const confirmButton=task.buttons![0][1]; const skipButton=task.buttons![0][2]; @@ -158,6 +167,17 @@ export const doChatsTasks=async function (client: telegram.TelegramClient,worker await hero.goto(urlButton.url.replace("https","http"),{timeoutMs:180_000}); await hero.waitForLoad('AllContentLoaded',{timeoutMs:180_000}); let captchaButton=hero.document.querySelector('button.g-recaptcha.btn.btn-primary'); + if (isNull(captchaButton)){ + if (prevTask.task.message==task.message){ + logger.warn(`Same tasks detected on ${worker.phoneNumber}... Skipping due captcha isnt detected......`); + await skipButton.click({sharePhone: false}); + } else { + prevTask.task=task; + logger.warn(`Captcha isnt detected... | ${worker.phoneNumber}`); + } + + continue mainLoop; + } while (captchaButton!=null && await hero.activeTab.url==urlButton.url!){ const isCaptchaPassed=hero.document.querySelector("input[id='recaptcha-token']"); if ((isCaptchaPassed==null || await isCaptchaPassed.$isVisible==false) ){ @@ -275,6 +295,7 @@ export const doChatsTasks=async function (client: telegram.TelegramClient,worker }))[0]; if (afterTask!=null && group){ + prevTask.task=task; prevTask.lastMessage=afterTask; if (afterTask.message.includes(settings.botMessages.taskComplete)==true){ worker.completedGroupsTasks.push( diff --git a/database.ts b/database.ts index 9488cd0..5ccc37e 100644 --- a/database.ts +++ b/database.ts @@ -151,7 +151,8 @@ export class Settings implements interfacesSettings.settingsInterface { verification: 'To continue using this bot,', tasksSelector: 'Choose an option to start earning your TRX', taskOver: 'Sorry, there are no new ads available.', - taskComplete: 'Success, ' + taskComplete: 'Success, ', + notInGroup: 'not entered the chat' }, botButtons: { earn: '❇️ Earn cryptocurrency', @@ -168,7 +169,7 @@ export class Settings implements interfacesSettings.settingsInterface { mainCrypto: "TRX"; minimalToWithdraw: number; maxRefferals: number; - botMessages: { verification: string; tasksSelector: string; taskOver: string, taskComplete: string}; + botMessages: { verification: string; tasksSelector: string; taskOver: string, taskComplete: string, notInGroup: string}; botButtons: { earn: string; balance: string; withdraw: string; }; telegramLinks: { botLink: string; groupsToJoin: string[]; }; bypassMode: boolean @@ -186,8 +187,24 @@ export class Settings implements interfacesSettings.settingsInterface { throw new Error("Config doesn't setup"); }); } else { - for (const setting of Object.keys(result)){ - this[setting]=result[setting]; + mainLoop: + for (const setting of Object.keys(this.default)){ + if (result[setting]===undefined || typeof(result[setting])!=typeof(this.default[setting])){ + console.log(result[setting],this.default[setting],result[setting]!==this.default[setting]) + this[setting]=this.default[setting]; + logger.warn(`Setting '${setting}' corrupted. Check out it...`) + } else { + if (typeof(result[setting])=='object'){ + for (const attr of Object.keys(this.default[setting])){ + if (Object.keys(result[setting]).indexOf(attr)==-1){ + this[setting] = this.default[setting]; + logger.warn(`Setting '${setting}' corrupted. Check out it...`) + continue mainLoop; + } + } + } + this[setting]=result[setting]; + } } logger.level=this.logLevel; } diff --git a/interfaces/settingsInterface.d.ts b/interfaces/settingsInterface.d.ts index 47801d4..cf6d9fc 100644 --- a/interfaces/settingsInterface.d.ts +++ b/interfaces/settingsInterface.d.ts @@ -10,7 +10,8 @@ export interface settingsInterface { verification: string, tasksSelector: string, taskOver: string, - taskComplete: string + taskComplete: string, + notInGroup: string } // to send botButtons:{