trailuoimodule
v1.0.3
Published
Trai Luoi Module for Tool. Contact me for more information. https://t.me/TraiLuoi
Downloads
1
Maintainers
Readme
TRAI LUOI DATA TELEGRAM COLLECT
1. Tải Module
npm i trailuoimodule2. Config
import TelegramDataCollectorSP from 'trailuoimodule';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const projectRoot = path.resolve(__dirname, '.');
const pathToLocalStorage = path.join(projectRoot, 'LocalStorage');
const pathToProxy = path.join(projectRoot, 'Proxy.txt');
const pathToLogData = path.join(projectRoot, 'LogData.txt');
const pathToUA = path.join(projectRoot, 'UA.json');
const userAgents = JSON.parse(fs.readFileSync(pathToUA, 'utf8'));
const urlTelegram = `https://web.telegram.org/k/#?tgaddr=tg%3A%2F%2Fresolve%3Fdomain%3DUXUYbot%26appname%3Dapp%26startapp%3D`
let accountsToProcess = [];
let ProcessRun = false;
const collector = new TelegramDataCollectorSP({
pathToLocalStorage: pathToLocalStorage,
pathToLogData: pathToLogData,
pathToLogProxy: pathToLogProxy,
urlTelegram: urlTelegram,
userAgents: userAgents
});3. Gọi module
function ParseTgLogin(tg_login) {
const params = new URLSearchParams(tg_login);
const queryId = params.get('query_id') || null;
const user = params.get('user') ? JSON.parse(decodeURIComponent(params.get('user'))) : null;
const authDate = params.get('auth_date') || null;
const signature = params.get('signature') || null;
const hash = params.get('hash') || null;
const startParam = params.get('start_param') || null;
const userId = user?.id || null;
const firstName = user?.first_name || null;
const lastName = user?.last_name || null;
const username = user?.username || null;
const languageCode = user?.language_code || null;
const allowsWriteToPm = user?.allows_write_to_pm || null;
const photoUrl = user?.photo_url || null;
return {
queryId,
userId,
firstName,
lastName,
username,
languageCode,
allowsWriteToPm,
photoUrl,
authDate,
signature,
hash,
startParam
}
}
function writeTgLogin(accID, tg_login) {
const accountData = JSON.parse(fs.readFileSync(pathToAccount, 'utf8'));
const account = accountData.find(acc => acc.name === accID);
if (!account) {
console.error(Red, `Không tìm thấy tài khoản với UseName: ${accID}` + '\n' + '-'.repeat(50));
return;
}
account.tg_login = tg_login;
fs.writeFileSync(pathToAccount, JSON.stringify(accountData, null, 2), 'utf8');
}
async function ProcessAccounts() {
if (accountsToProcess.length > 0) {
ProcessRun = true;
const account = accountsToProcess[0];
const [accID, tg_login, Proxy] = account;
const { startParam } = ParseTgLogin(tg_login)
const result = await collector.getTgData(accID, startParam, Proxy);
if (result) {
writeTgLogin(accID, result)
}
accountsToProcess.shift(); // Remove the processed account from the list
ProcessAccounts(); // Process the next account
}
}