modified: database.ts
This commit is contained in:
parent
e32f9a6f55
commit
158e772ccc
70
database.ts
70
database.ts
|
@ -1,5 +1,5 @@
|
|||
import {JsonDB,Config} from "node-json-db"
|
||||
import {BrowserFingerprintWithHeaders} from "fingerprint-generator"
|
||||
import {Fingerprint, FingerprintGenerator} from "fingerprint-generator"
|
||||
import logger from "./logger"
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ interface AccountInterface {
|
|||
withdraws:AccountWithdrawInterface[],
|
||||
completedGroupsTasks:AccountCompletedGroupsTasksInterface[],
|
||||
canBeRefferal: boolean,
|
||||
browserFingerprint:BrowserFingerprintWithHeaders,
|
||||
browserFingerprint:Fingerprint,
|
||||
refferal:number
|
||||
|
||||
}
|
||||
|
@ -60,22 +60,62 @@ class Database {
|
|||
}
|
||||
})
|
||||
}
|
||||
private async findWallet(){
|
||||
|
||||
}
|
||||
|
||||
async getUsers(){
|
||||
let rawUsers={};
|
||||
async addUser(account: Omit<AccountInterface,
|
||||
'balance' | 'withdraws' | 'completedGroupsTasks' | 'canBeRefferal'
|
||||
| 'browserFingerprint' | 'faucetMail'>): Promise<void>{
|
||||
const fingerprintGenerator = new FingerprintGenerator();
|
||||
const fingerprint=fingerprintGenerator.getFingerprint({
|
||||
devices: ['desktop'],
|
||||
browsers: ['chrome'],
|
||||
|
||||
}).fingerprint;
|
||||
|
||||
|
||||
// var faucetWallet={};
|
||||
// for (const _wallet in wallets){
|
||||
// var flag=false;
|
||||
|
||||
// if (accounts.length>0){
|
||||
// for (const account of accounts){
|
||||
// if (account.faucetMail[0]==_wallet ){
|
||||
// flag=true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (flag==false){
|
||||
// faucetWallet[_wallet]=wallets[_wallet];
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
await this.json.push(`/accounts[]`,{
|
||||
phoneNumber:account.phoneNumber,
|
||||
telegramID:account.telegramID,
|
||||
apiId:account.apiID,
|
||||
apiHash:account.apiHash,
|
||||
password:account.password,
|
||||
faucetMail:{},
|
||||
stringSession:account.stringSession,
|
||||
balance:0.0,
|
||||
withdraws:[],
|
||||
completedGroupTasks:[],
|
||||
canBeRefferal:Math.random() < 0.5,
|
||||
refferal:account.refferal,
|
||||
browserFingerprint:fingerprint
|
||||
})
|
||||
}
|
||||
|
||||
async getUsers(): Promise<AccountInterface[]>{
|
||||
try {
|
||||
rawUsers=await this.json.getData('/accounts');
|
||||
return await this.json.getData('/accounts');
|
||||
} catch {
|
||||
rawUsers={};
|
||||
}
|
||||
let arrayAccounts: AccountInterface[]=[];
|
||||
for (const _account in rawUsers){
|
||||
console.log()
|
||||
// arrayAccounts.push({
|
||||
|
||||
// });
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,4 +123,4 @@ class Database {
|
|||
}
|
||||
|
||||
|
||||
(new Database()).getUsers();
|
||||
(new Database()).getUsers();
|
||||
|
|
Loading…
Reference in a new issue