mirror of
https://github.com/hempyhemp/hh-auto-reply.git
synced 2026-06-08 18:04:57 +00:00
🚀 refactor(bot-commands): исправлена ошибка ответа на запрос пользователя, текст перебiraется пo LIMIT280个 символов
This commit is contained in:
@@ -160,7 +160,7 @@ export function registerHHCommands() {
|
|||||||
const messageId = query.message.message_id
|
const messageId = query.message.message_id
|
||||||
const state = getState(chatId)
|
const state = getState(chatId)
|
||||||
|
|
||||||
await bot.answerCallbackQuery(query.id)
|
await bot.answerCallbackQuery(query.id).catch(() => {})
|
||||||
|
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: { telegramId: chatId },
|
where: { telegramId: chatId },
|
||||||
@@ -205,11 +205,15 @@ export function registerHHCommands() {
|
|||||||
result.errors.forEach(v => lines.push(`• <a href="${v.href}">${v.title}</a> — ${v.message}`))
|
result.errors.forEach(v => lines.push(`• <a href="${v.href}">${v.title}</a> — ${v.message}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
await bot.sendMessage(chatId, lines.join('\n'), {
|
const fullText = lines.join('\n')
|
||||||
|
const LIMIT = 4000
|
||||||
|
for (let i = 0; i < fullText.length; i += LIMIT) {
|
||||||
|
await bot.sendMessage(chatId, fullText.slice(i, i + LIMIT), {
|
||||||
parse_mode: 'HTML',
|
parse_mode: 'HTML',
|
||||||
disable_web_page_preview: true,
|
disable_web_page_preview: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
await showMenu(chatId)
|
await showMenu(chatId)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
@@ -234,12 +238,12 @@ export function registerHHCommands() {
|
|||||||
await showResult(chatId, messageId, '📋 Резюме не найдено.\n\nВыбери резюме через кнопку 📄 Выбрать резюме.')
|
await showResult(chatId, messageId, '📋 Резюме не найдено.\n\nВыбери резюме через кнопку 📄 Выбрать резюме.')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const MAX = 10000
|
const MAX = 3500
|
||||||
const text = resume.data.length > MAX
|
const text = resume.data.length > MAX
|
||||||
? `${resume.data.slice(0, MAX)}\n\n… (текст обрезан)`
|
? `${resume.data.slice(0, MAX)}\n\n… (текст обрезан)`
|
||||||
: resume.data
|
: resume.data
|
||||||
await bot.editMessageText(
|
await bot.editMessageText(
|
||||||
`📋 <b>Твоё резюме</b>\n<pre>${escapeHtml(text)}</pre>`,
|
`📋 <b>Твоё резюме:</b>\n <b>${resume.title}</b>\n<pre>${escapeHtml(text)}</pre>`,
|
||||||
{
|
{
|
||||||
chat_id: chatId,
|
chat_id: chatId,
|
||||||
message_id: messageId,
|
message_id: messageId,
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ export async function saveResume(chatId: number, resumeItem: ResumeListItem): Pr
|
|||||||
let resume: string | undefined
|
let resume: string | undefined
|
||||||
try {
|
try {
|
||||||
resume = await page.locator('.resume').innerText()
|
resume = await page.locator('.resume').innerText()
|
||||||
|
await prisma.resume.deleteMany({ where: { telegramId: chatId, NOT: { id } } })
|
||||||
await prisma.resume.upsert({
|
await prisma.resume.upsert({
|
||||||
where: { id },
|
where: { id },
|
||||||
create: { data: resume, id, telegramId: chatId, title },
|
create: { data: resume, id, telegramId: chatId, title },
|
||||||
@@ -238,10 +239,20 @@ export async function applyToJobs(
|
|||||||
console.log('Ожидаемое резюме из БД:', resume.title)
|
console.log('Ожидаемое резюме из БД:', resume.title)
|
||||||
|
|
||||||
if (currentResumeTitle !== resume.title) {
|
if (currentResumeTitle !== resume.title) {
|
||||||
// TODO: добавить логику смены резюме
|
|
||||||
console.log('Резюме не совпадает, нужно сменить')
|
console.log('Резюме не совпадает, нужно сменить')
|
||||||
currentResumeEl?.focus()
|
await currentResumeEl?.click()
|
||||||
currentResumeEl?.click()
|
await page.waitForSelector('[data-qa="magritte-select-option-list"]', { timeout: 5000 })
|
||||||
|
await page.pause()
|
||||||
|
const options = await page.$$('label[role="option"]')
|
||||||
|
for (const option of options) {
|
||||||
|
const titleEl = await option.$('[data-qa="resume-title"] [data-qa="cell-text-content"]')
|
||||||
|
const title = (await titleEl?.innerText())?.trim()
|
||||||
|
if (title === resume.title) {
|
||||||
|
await option.click()
|
||||||
|
await page.waitForTimeout(randomDelay())
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await page.pause()
|
await page.pause()
|
||||||
|
|
||||||
@@ -252,8 +263,8 @@ export async function applyToJobs(
|
|||||||
await addLetter?.click()
|
await addLetter?.click()
|
||||||
}
|
}
|
||||||
|
|
||||||
await keep(`✅ <b>${vacancy.title}</b>\n\n${letter}`)
|
|
||||||
const letter = await letterPromise
|
const letter = await letterPromise
|
||||||
|
await keep(`✅ <b>${vacancy.title}</b>\n\n${letter}`)
|
||||||
|
|
||||||
if (letter) {
|
if (letter) {
|
||||||
const letterInput = await page.$('[data-qa="vacancy-response-popup-form-letter-input"]')
|
const letterInput = await page.$('[data-qa="vacancy-response-popup-form-letter-input"]')
|
||||||
|
|||||||
Reference in New Issue
Block a user