31 lines
1020 B
Python
31 lines
1020 B
Python
import asyncio
|
|
|
|
from django.core.management import BaseCommand
|
|
from vacancies.main.models import CustomerCV
|
|
from vacancies.main.bot import application
|
|
from vacancies.main.vector_store import get_next_vacancy
|
|
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
|
|
|
|
|
|
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():
|
|
result = get_next_vacancy(customer_cv)
|
|
if not result:
|
|
continue
|
|
|
|
recommendation, vacancy_content, link = result
|
|
|
|
await application.bot.send_message(
|
|
chat_id=recommendation.customer.chat_id,
|
|
text=vacancy_content,
|
|
reply_markup=InlineKeyboardMarkup([[
|
|
InlineKeyboardButton("Откликнуться", url=link),
|
|
]]),
|
|
)
|