diff --git a/src/hh/handlers/settings.ts b/src/hh/handlers/settings.ts index 90fbf00..0339c37 100644 --- a/src/hh/handlers/settings.ts +++ b/src/hh/handlers/settings.ts @@ -2,7 +2,7 @@ import bot from '@bot' import prisma from '@prisma' import cron from 'node-cron' import { clearVacancyCache } from '../scraper.js' -import { buildSettingsKeyboard, escapeHtml } from '../ui.js' +import { buildFiltersKeyboard, buildSettingsKeyboard, escapeHtml } from '../ui.js' import { getState } from '../state.js' export async function handleSearchModeToggle(chatId: number): Promise { @@ -15,7 +15,7 @@ export async function handleSearchModeToggle(chatId: number): Promise { const text = next === 'resume' ? `✅ Поиск по резюме включён\n\n• Есть ключевые слова → ?text=...&resume=...\n• Ключевые слова пусты → только ?resume=...` : `⛔ Поиск по резюме выключен\n\n• Всегда ищет по ключевым словам → ?text=...` - await bot.sendMessage(chatId, text, { parse_mode: 'HTML', reply_markup: await buildSettingsKeyboard(chatId) }) + await bot.sendMessage(chatId, text, { parse_mode: 'HTML', reply_markup: await buildFiltersKeyboard(chatId) }) } export async function handleQuery(chatId: number): Promise { diff --git a/src/hh/scraper.ts b/src/hh/scraper.ts index 195b756..549c217 100644 --- a/src/hh/scraper.ts +++ b/src/hh/scraper.ts @@ -100,15 +100,14 @@ async function skipIfQuestionnaire( vacancy: { title: string, href: string }, ref: VacancyRef, chatId: number, - status: (msg: string) => Promise, + keep: (msg: string) => Promise, results: ApplyResult, ): Promise { await page.waitForSelector(APPLY_OUTCOME_SELECTOR, { timeout: 5000 }).catch(() => {}) const hasQuestionnaire = await page.$('[data-qa="employer-asking-for-test"], [data-qa="task-body"]') if (!hasQuestionnaire) return false - const { keep } = createStatusReporter(chatId) - await keep(`Пропущена вакансия: ${vacancy.title}`) + await keep(`⏭ Пропущена: требует заполнения анкеты/теста\n${escapeHtml(vacancy.title)}`) log.warn(`[x] ${vacancy.title} hasQuestionnaire`) await prisma.skippedVacancy.upsert({ where: { telegramId_href: { telegramId: chatId, href: vacancy.href } }, @@ -431,6 +430,7 @@ export async function applyToJobs( .catch(() => '') if (!description) { + await keep(`⏭ Пропущена: описание недоступно\n${escapeHtml(vacancy.title)}`) results.skipped.push(ref) consecutiveSkips++ continue @@ -438,6 +438,7 @@ export async function applyToJobs( const applyBtn = await page.$('[data-qa="vacancy-response-link-top"]') if (!applyBtn) { + await keep(`⏭ Пропущена: уже откликались или кнопка не найдена\n${escapeHtml(vacancy.title)}`) results.skipped.push(vacancy) consecutiveSkips++ continue @@ -451,7 +452,7 @@ export async function applyToJobs( if (relocationConfirm) await relocationConfirm.click() - if (await skipIfQuestionnaire(page, vacancy, ref, chatId, status, results)) { + if (await skipIfQuestionnaire(page, vacancy, ref, chatId, keep, results)) { consecutiveSkips++ continue } diff --git a/src/hh/ui.ts b/src/hh/ui.ts index 6268199..0285917 100644 --- a/src/hh/ui.ts +++ b/src/hh/ui.ts @@ -38,13 +38,11 @@ export const MAIN_REPLY_KEYBOARD = { } export async function buildSettingsKeyboard(chatId: number) { - const settings = await prisma.settings.findUnique({ where: { telegramId: chatId } }) - const modeLabel = settings?.searchMode === 'resume' ? 'резюме' : 'текст' return { keyboard: [ [{ text: BTN.MAX }, { text: BTN.AUTO_TOGGLE }], [{ text: BTN.RESUME_LIST }, { text: BTN.PROMPT }], - [{ text: `${BTN.SEARCH_MODE_TOGGLE}: ${modeLabel}` }, { text: BTN.LOGIN }], + [{ text: BTN.LOGIN }], [{ text: BTN.BACK }], ], resize_keyboard: true, @@ -54,12 +52,14 @@ export async function buildSettingsKeyboard(chatId: number) { export async function buildFiltersKeyboard(chatId: number) { const settings = await prisma.settings.findUnique({ where: { telegramId: chatId } }) + const modeLabel = settings?.searchMode === 'resume' ? 'резюме' : 'текст' const fullLabel = areaLabel(settings?.area) const regionShort = fullLabel.split(' ').slice(1).join(' ') return { keyboard: [ [{ text: BTN.QUERY }], [{ text: BTN.EXCLUSIONS }, { text: `${BTN.REGION}: ${regionShort}` }], + [{ text: `${BTN.SEARCH_MODE_TOGGLE}: ${modeLabel}` }], [{ text: BTN.BACK }], ], resize_keyboard: true,