mirror of
https://github.com/hempyhemp/hh-auto-reply.git
synced 2026-06-08 18:04:57 +00:00
🔨 refactor(browser/scraper): Код оптимизирован и обработка ошибок улучшена
All checks were successful
Deploy / deploy (push) Successful in 46s
All checks were successful
Deploy / deploy (push) Successful in 46s
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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,8 +102,11 @@ 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) {
|
||||
const browser = await getBrowser()
|
||||
|
||||
Reference in New Issue
Block a user