vision-career/vacancies/main/management/commands/generate_recommended_vacancies.py
estromenko b224ef29d3
All checks were successful
release / docker (push) Successful in 38s
Improve vacancy rendering in messages
2025-11-09 23:41:52 +03:00

28 lines
1010 B
Python

import asyncio
from django.core.management import BaseCommand
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from vacancies.main.bot import application
from vacancies.main.models import CustomerCV
from vacancies.main.recommendations import get_next_vacancy
class Command(BaseCommand):
help = "Generates new recommended vacancies"
def handle(self, *args, **options):
asyncio.run(self.ahandle(*args, **options))
async def ahandle(self, *args, **options):
for customer_cv in CustomerCV.objects.all():
if vacancy := get_next_vacancy(customer_cv):
await application.bot.send_message(
chat_id=customer_cv.customer.chat_id,
text=vacancy.get_formatted_response(),
parse_mode="Markdown",
reply_markup=InlineKeyboardMarkup([[
InlineKeyboardButton("Откликнуться", url=vacancy.link),
]]),
)