🔨 refactor(browser/scraper): Код оптимизирован и обработка ошибок улучшена
All checks were successful
Deploy / deploy (push) Successful in 46s

This commit is contained in:
Oscar
2026-05-28 15:30:32 +03:00
parent 1273eff7b7
commit a2b3539f35
2 changed files with 44 additions and 32 deletions

View File

@@ -16,7 +16,15 @@ export async function randomScroll(page: Page): Promise<void> {
}
export async function getBrowser(): Promise<Browser> {
return chromium.launch({ headless: !!(process.env?.debug ?? true) })
return chromium.launch({
headless: !!(process.env?.debug ?? true),
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-gpu',
],
})
}
export async function loadSession(page: Page, telegramId: bigint | number): Promise<boolean> {

View File

@@ -61,6 +61,7 @@ export async function login(email: string, chatId: number): Promise<void> {
return
}
try {
const context = await browser.newContext()
const page = await context.newPage()
@@ -101,7 +102,10 @@ export async function login(email: string, chatId: number): Promise<void> {
})
await bot.sendMessage(chatId, cookies.length > 0 ? '✅ Авторизация выполнена' : '❌ Произошла ошибка')
}
finally {
await browser.close()
}
}
export async function checkIsAuth(telegramId: bigint | number) {