This commit is contained in:
”minicx” 2022-12-03 08:37:20 +03:00
parent cfcb20a780
commit 0a9792a598
6 changed files with 98 additions and 27 deletions

View File

@ -16,7 +16,7 @@ export const vertification=async function (client: telegram.TelegramClient,worke
let verify=hero.document.querySelector('body > section > h2');
while (verify!=null && (await verify.textContent)!.includes('All right!')==false){
const isCaptchaPassed=hero.document.querySelector("input[id='recaptcha-token']");
if (isCaptchaPassed==null){
if (isCaptchaPassed==null || await isCaptchaPassed.$isVisible==false){
await hero.interact({click:{element: captchaButton, verification: 'exactElement'}});
await sleep(5000);
verify=hero.document.querySelector('body > section > h2');
@ -50,9 +50,69 @@ export const do_sites_task=async function (client: telegram.TelegramClient,worke
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');
console.log(task.message)
let captchaButton=hero.document.querySelector('button.g-recaptcha.btn.btn-primary');
if (captchaButton!=null && urlButton.url!.includes('hkbots')==true){
if (await captchaButton.$isClickable!=true){
// timer page
logger.warn('Found timer...')
if (settings.bypassMode==true){
logger.warn('Bypassing timer...')
try {
await hero.executeJs("document.getElementById('form').setAttribute('style', '')");
} catch (err){
logger.error(`Something went wrong due bypass`);
}
} else {
while (hero.document.querySelector("i[id='timer']")!=null && await captchaButton.$isClickable!=true){
await sleep(1000);
}
}
}
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) && await captchaButton.$isClickable==true){
try {
await hero.interact({click:{element: captchaButton, verification: 'exactElement'}});
} catch( err){
logger.warn(`Some error due clicking`);
continue
}
await sleep(5000);
captchaButton=hero.document.querySelector('button.g-recaptcha.btn.btn-primary');
} else {
logger.error("catpcha detected");
throw new Error("Auhtung captcha detected");
}
}
await waitNewMessages(client,worker,botEntity,prevTask.task.id);
let afterTask:telegram.Api.Message=(await client.getMessages(botEntity,{
minId:prevTask.task.id,
// search: settings.botMessages.tasksSelector,
}))[0];
if (afterTask!=null){
prevTask.lastMessage=afterTask;
if (afterTask.message.includes(settings.botMessages.taskComplete)==true){
logger.debug(`Site task complete | ${worker.phoneNumber}`);
continue
}
}
console.log(afterTask,afterTask.message)
}
} else if (task.message.includes(settings.botMessages.taskOver)==true){
break
} else {

View File

@ -3,6 +3,8 @@ import {FingerprintGenerator} from "fingerprint-generator"
import logger from "./logger"
import * as interfacesDB from "./interfaces/databaseInterface"
import * as interfacesSettings from "./interfaces/settingsInterface"
import { arrayWithoutElementAtIndex } from "./utils"
export class Database {
public readonly default: interfacesDB.DatabaseInterface={
accounts:[]
@ -66,9 +68,7 @@ export class Database {
let counter=0;
if (mainAccount.canBeRefferal==true){
let _accounts=accounts;
delete _accounts[accounts.indexOf(mainAccount)];
let _accounts=arrayWithoutElementAtIndex(accounts,accounts.indexOf(mainAccount));
for (const _account of _accounts){
if (_account.refferal==mainAccount.telegramID){
@ -147,7 +147,8 @@ export class Settings implements interfacesSettings.settingsInterface {
botMessages: {
verification: 'To continue using this bot,',
tasksSelector: 'Choose an option to start earning your TRX',
taskOver: 'Sorry, there are no new ads available.'
taskOver: 'Sorry, there are no new ads available.',
taskComplete: 'TRX has been added to your balance.'
},
botButtons: {
earn: '❇️ Earn cryptocurrency',
@ -164,7 +165,7 @@ export class Settings implements interfacesSettings.settingsInterface {
mainCrypto: "TRX";
minimalToWithdraw: number;
maxRefferals: number;
botMessages: { verification: string; tasksSelector: string; taskOver: string};
botMessages: { verification: string; tasksSelector: string; taskOver: string, taskComplete: string};
botButtons: { earn: string; balance: string; withdraw: string; };
telegramLinks: { botLink: string; groupsToJoin: string[]; };
bypassMode: boolean

View File

@ -13,6 +13,7 @@ import Miner from '@ulixee/miner';
import Hero from '@ulixee/hero';
import {ipInterface} from "./interfaces/otherInterfaces"
import { do_sites_task, vertification } from './automatization';
import ExecuteJsPlugin from '@ulixee/execute-js-plugin';
const addAccounts: ()=>Promise<void>=async ()=>{
let apiId: number=0
@ -154,20 +155,19 @@ const farm: ()=>Promise<void>=async ()=>{
ip.current=(await getIP(ports[0]))!;
}
ip.prev.push(ip.current)
const miner = new Miner();
await miner.listen({port: ports[-1]});
const fingerprint=worker.browserFingerprint
let hero: Omit<Hero, "then">;
while (true){
try {
hero = await new Hero({
hero = new Hero({
userProfile:{
deviceProfile: {
deviceMemory:fingerprint.navigator.deviceMemory,
}
},
name:`${worker.telegramID}`,
connectionToCore: { host:`ws://${await miner.address}` },
connectionToCore: { host:`ws://127.0.0.1:${ports[3]}` },
disableDevtools: true, // to bypass hk site
showChrome:true, // to debug
userAgent:fingerprint.navigator.userAgent,
@ -176,6 +176,7 @@ const farm: ()=>Promise<void>=async ()=>{
upstreamProxyUrl:`socks5://127.0.0.1:${ports[1]}`,
});
hero.use(ExecuteJsPlugin);
break;
} catch (err){
logger.warn(`Some error due openning Hero. Trying again...\n${err}`);
@ -228,6 +229,7 @@ const farm: ()=>Promise<void>=async ()=>{
// search: settings.botMessages.tasksSelector,
}))[0];
if (tasksSelector.message.includes(settings.botMessages.verification)==true){
logger.warn(`Account ${worker.phoneNumber} is unvertificated`)
const url: string=tasksSelector.buttons![0][0].url!;
await vertification(client,worker,hero,url,botEntity,tasksSelector.id);
const requestTasksMessage=await client.sendMessage(botEntity,{message:settings.botButtons.earn});
@ -249,7 +251,6 @@ const farm: ()=>Promise<void>=async ()=>{
await hero.close();
await miner.close();
}
@ -261,29 +262,32 @@ const farm: ()=>Promise<void>=async ()=>{
const workers=await db.getUsers();
let workers_groups: Array<AccountInterface[]>=[];
let workersGroups: Array<AccountInterface[]>=[];
for (let i=0;i!=settings.pararels+1;i+=settings.pararels){
for (let i=0;i!=workers.length+1;i+=settings.pararels){
const _workers=workers.slice(i,i+settings.pararels);
if (_workers.length!=0){
workers_groups.push(_workers);
workersGroups.push(_workers);
} else {
break;
}
}
if (workers_groups.length!=Math.ceil(workers.length/settings.pararels)){
logger.warn(`There is strange thing with workers_group\n${workers_groups.length} ${Math.ceil(workers.length/settings.pararels)}`);
if (workersGroups.length!=Math.ceil(workers.length/settings.pararels)){
logger.warn(`There is strange thing with workers_group\n${workersGroups.length} ${Math.ceil(workers.length/settings.pararels)}`);
}
let pararels: Promise<void>[] =[]
let _ports=await findFreePorts(settings.pararels*4);
for (let i=0;i!=settings.pararels;i++){
let pararels: Promise<void>[] =[];
let _ports=await findFreePorts(workers.length*3+1);
const miner = new Miner();
await miner.listen({port: _ports[_ports.length-1]});
for (let i=0;i!=workersGroups.length;i++){
let ports=_ports.slice(i*3,i*3+3);
ports.push(_ports[_ports.length-1]);
pararels.push(proccesGroup(workersGroups[i],ports));
}
for (let i=0;i!=workers_groups.length;i++){
pararels.push(proccesGroup(workers_groups[i],_ports.slice(i*4,i*4+4)));
}
await Promise.all(pararels);
console.log(_ports);
await Promise.all(pararels);
await miner.close();
}
// menu

View File

@ -9,7 +9,8 @@ export interface settingsInterface {
botMessages: {
verification: string,
tasksSelector: string,
taskOver: string
taskOver: string,
taskComplete: string
}
// to send
botButtons:{

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"@ulixee/execute-js-plugin": "^2.0.0-alpha.15",
"@ulixee/hero": "^2.0.0-alpha.15",
"@ulixee/miner": "^2.0.0-alpha.15",
"axios": "^1.2.0",

View File

@ -21,7 +21,11 @@ export const getMessagesByEntity=async function(client:telegram.TelegramClient,c
}
return messages;
}
export const arrayWithoutElementAtIndex = function (arr: AccountInterface[] | [], index: number) {
return arr.filter(function(value, arrIndex) {
return index !== arrIndex;
});
}
export const getIP=async function (proxyPort: number): Promise<string | null> {
const {data}=await axios.get('http://api.ipify.org',{