Exemplo n.º 1
0
def sqlQuery(message, vacancy: str):
    try:
        doc_name = info.getCSV(command=vacancy)
        with open(doc_name, 'rb') as document:
            bot.send_document(message.chat.id, document)
        if os.path.isfile(doc_name):
            os.remove(doc_name)
    except Exception as e:
        bot.send_message(message.chat.id, e)
        init.updateErrors(message.chat.id, message.chat.username, message.text,
                          e)
Exemplo n.º 2
0
def showVac(message, vacancy: str):
    try:
        text = info.getVacancies(vacancy)
        bot.send_message(
            message.chat.id,
            text,
            reply_markup=vacanciesKeyboard(str(5) + '_' + vacancy),
            disable_web_page_preview=True)
    except Exception as e:
        bot.send_message(message.chat.id, e)
        init.updateErrors(message.chat.id, message.chat.username, message.text,
                          e)
Exemplo n.º 3
0
def downloadVac(message, vacancy: str):
    try:
        doc_name = info.getCSV(f'select * from public."{vacancy}"')
        with open(doc_name, 'rb') as document:
            bot.send_document(message.chat.id,
                              document,
                              reply_markup=commandsKeyboard(vacancy))
        if os.path.isfile(doc_name):
            os.remove(doc_name)
    except Exception as e:
        bot.send_message(message.chat.id, e)
        init.updateErrors(message.chat.id, message.chat.username, message.text,
                          e)
Exemplo n.º 4
0
def experienceVac(message, vacancy: str):
    try:
        # res = ('file_name', count_vacancies)
        res = analize.experienceRate(vacancy)
        with open(res[0], 'rb') as photo:
            bot.send_photo(message.chat.id, photo)
        if os.path.isfile(res[0]):
            os.remove(res[0])
        text = f'На основе {res[1]} вакансий по запросу <code>{vacancy}</code>'
        bot.send_message(message.chat.id,
                         text,
                         reply_markup=commandsKeyboard(vacancy))
    except Exception as e:
        bot.send_message(message.chat.id, e)
        init.updateErrors(message.chat.id, message.chat.username, message.text,
                          e)
Exemplo n.º 5
0
def updateVac(message, vacancy: str):
    try:
        bot.send_message(message.chat.id, 'Это может занять некторое время')
        init.getData(vacancy, message, bot)
        bot.send_message(message.chat.id,
                         'Данные по вакансии доступны к анализу',
                         reply_markup=commandsKeyboard(vacancy))
    except Exception as e:
        if str(e) == 'Вакансий по запросу не найдено':
            bot.send_message(message.chat.id,
                             f'{e}, проверь правильность запроса /help')
        else:
            bot.send_message(message.chat.id, 'Что-то пошло не так :с /help')
            bot.send_message(message.chat.id, e)
            init.updateErrors(message.chat.id, message.chat.username,
                              message.text, e)
Exemplo n.º 6
0
def skillsVac(message, vacancy: str):
    try:
        # res = ('file_name', [skills], count_vacancies)
        res = analize.headSkills(vacancy)
        with open(res[0], 'rb') as photo:
            bot.send_photo(message.chat.id, photo)
        if os.path.isfile(res[0]):
            os.remove(res[0])
        text = f'Самые популярные навыки в {res[2]} вакансиях по запросу ' \
                f'<code>{vacancy}</code>: <b>{res[1][0]}, {res[1][1]}, {res[1][2]}</b>'
        bot.send_message(message.chat.id,
                         text,
                         reply_markup=commandsKeyboard(vacancy))
    except Exception as e:
        bot.send_message(message.chat.id, e)
        init.updateErrors(message.chat.id, message.chat.username, message.text,
                          e)
Exemplo n.º 7
0
def callback_answer(message):
    if message.data in info.getTablesNames():
        bot.send_message(
            message.message.chat.id,
            f'Какую информацию по запросу <code>{message.data}</code> хочешь получить?',
            reply_markup=commandsKeyboard(message.data))
    else:
        # msg = [vacancy_number_on_current_page, vacancy_name, callback(first/next)]
        msg = message.data.split('_')
        try:
            if msg[2] == 'next':
                text = info.getVacancies(msg[1], int(msg[0]), int(msg[0]) + 5)

                # take int(vacancy_number) from string
                count = 3
                while text[count] != '.':
                    count += 1
                num = int(text[3:count]) + 4

                bot.edit_message_text(
                    text,
                    message.message.chat.id,
                    message.message.id,
                    reply_markup=vacanciesKeyboard(str(num) + '_' + msg[1]),
                    disable_web_page_preview=True)
            elif msg[2] == 'first':
                text = info.getVacancies(msg[1])
                bot.edit_message_text(
                    text,
                    message.message.chat.id,
                    message.message.id,
                    reply_markup=vacanciesKeyboard(str(5) + '_' + msg[1]),
                    disable_web_page_preview=True)
        except IndexError:
            bot.edit_message_reply_markup(
                message.message.chat.id,
                message.message.id,
                reply_markup=vacanciesKeyboard(str(0) + '_' + msg[1]))
        except Exception as e:
            init.updateErrors(message.message.chat.id,
                              message.message.chat.username, message.data, e)
Exemplo n.º 8
0
def salaryVac(message, vacancy: str):
    try:
        # res = ('file_name', averageSalary, count_vacancies_with_salary, count_vacancies)
        res = analize.averageSalary(vacancy)
        if res[0] != 'No graph':
            with open(res[0], 'rb') as photo:
                bot.send_photo(message.chat.id, photo)
            if os.path.isfile(res[0]):
                os.remove(res[0])
        text = f'<b>{res[1]}</b> - средняя зарплата по запросу <code>{vacancy}</code>\n' \
                f'Из {res[3]} вакансий зарплата указана в {res[2]}'
        bot.send_message(message.chat.id,
                         text,
                         reply_markup=commandsKeyboard(vacancy))
    except Exception as e:
        if str(e) == 'Зарпалата не указана ни в одной вакансии':
            bot.send_message(message.chat.id,
                             e,
                             reply_markup=commandsKeyboard(vacancy))
        else:
            bot.send_message(message.chat.id, e)
            init.updateErrors(message.chat.id, message.chat.username,
                              message.text, e)