mirror of https://github.com/Bunsly/JobSpy
init for adding country to user model
parent
5fe8231455
commit
c1e30a00df
18
src/main.py
18
src/main.py
|
@ -28,23 +28,17 @@ if __name__ == "__main__":
|
||||||
application.add_handler(CommandHandler("find", tg_handler_all.handle))
|
application.add_handler(CommandHandler("find", tg_handler_all.handle))
|
||||||
# Goozali
|
# Goozali
|
||||||
tg_handler_goozali = TelegramDefaultHandler(sites=[Site.GOOZALI])
|
tg_handler_goozali = TelegramDefaultHandler(sites=[Site.GOOZALI])
|
||||||
application.add_handler(CommandHandler(
|
application.add_handler(CommandHandler(Site.GOOZALI.value, tg_handler_goozali.handle))
|
||||||
Site.GOOZALI.value, tg_handler_goozali.handle))
|
|
||||||
# GlassDoor
|
# GlassDoor
|
||||||
tg_handler_glassdoor = TelegramDefaultHandler(sites=[Site.GLASSDOOR])
|
tg_handler_glassdoor = TelegramDefaultHandler(sites=[Site.GLASSDOOR])
|
||||||
application.add_handler(CommandHandler(
|
application.add_handler(CommandHandler(Site.GLASSDOOR.value, tg_handler_glassdoor.handle))
|
||||||
Site.GLASSDOOR.value, tg_handler_glassdoor.handle))
|
|
||||||
# LinkeDin
|
# LinkeDin
|
||||||
tg_handler_linkedin = TelegramDefaultHandler(sites=[Site.LINKEDIN])
|
tg_handler_linkedin = TelegramDefaultHandler(sites=[Site.LINKEDIN])
|
||||||
application.add_handler(CommandHandler(
|
application.add_handler(CommandHandler(Site.LINKEDIN.value, tg_handler_linkedin.handle))
|
||||||
Site.LINKEDIN.value, tg_handler_linkedin.handle))
|
|
||||||
# Indeed
|
# Indeed
|
||||||
tg_handler_indeed = TelegramDefaultHandler(sites=[Site.INDEED])
|
tg_handler_indeed = TelegramDefaultHandler(sites=[Site.INDEED])
|
||||||
application.add_handler(CommandHandler(
|
application.add_handler(CommandHandler(Site.INDEED.value, tg_handler_indeed.handle))
|
||||||
Site.INDEED.value, tg_handler_indeed.handle))
|
application.add_handler(CommandHandler("myInfo", my_info_handler.handle))
|
||||||
application.add_handler(CommandHandler(
|
application.add_handler(CallbackQueryHandler(tg_callback_handler.button_callback))
|
||||||
"myInfo", my_info_handler.handle))
|
|
||||||
application.add_handler(CallbackQueryHandler(
|
|
||||||
tg_callback_handler.button_callback))
|
|
||||||
logger.info("Run polling from telegram")
|
logger.info("Run polling from telegram")
|
||||||
application.run_polling(allowed_updates=Update.ALL_TYPES)
|
application.run_polling(allowed_updates=Update.ALL_TYPES)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from model.Position import Position
|
from model.Position import Position
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ class User(BaseModel):
|
||||||
experience: Union[int, str] = None
|
experience: Union[int, str] = None
|
||||||
job_age: Union[int, str] = None
|
job_age: Union[int, str] = None
|
||||||
position: Optional[Position] = None
|
position: Optional[Position] = None
|
||||||
|
country: Optional[str] = None
|
||||||
cities: Optional[list[str]] = None
|
cities: Optional[list[str]] = None
|
||||||
title_filters: Optional[list[str]] = None
|
title_filters: Optional[list[str]] = None
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ START_MESSAGE: str = "Hi there! I'm JobSeeker Bot, your friendly job search assi
|
||||||
"I'm here to help you find the perfect position.\n\n" \
|
"I'm here to help you find the perfect position.\n\n" \
|
||||||
"To stop chatting with me at any time, just send '/cancel'.\n\n"
|
"To stop chatting with me at any time, just send '/cancel'.\n\n"
|
||||||
|
|
||||||
POSITION_MESSAGE: str = "What kind of position are you looking for? ✨\n" \
|
POSITION_MESSAGE: str = "What kind of position are you looking for? ✨\n\n" \
|
||||||
"(e.g., Software Engineer, Data Scientist, Marketing Manager)"
|
"(e.g., Software Engineer, Data Scientist, Marketing Manager)"
|
||||||
|
|
||||||
POSITION_NOT_FOUND: str = "I couldn't find any positions matching your request. 😕\n" \
|
POSITION_NOT_FOUND: str = "I couldn't find any positions matching your request. 😕\n" \
|
||||||
|
@ -17,7 +17,7 @@ EXPERIENCE_MESSAGE: str = "How many years of professional experience do you have
|
||||||
EXPERIENCE_INVALID: str = "Oops! Please enter your experience in years as a number.😕\n" \
|
EXPERIENCE_INVALID: str = "Oops! Please enter your experience in years as a number.😕\n" \
|
||||||
"For example, 2, 5, or 10."
|
"For example, 2, 5, or 10."
|
||||||
|
|
||||||
JOB_AGE_MESSAGE: str = "How recent should the jobs be? ⏰\n" \
|
JOB_AGE_MESSAGE: str = "How recent should the jobs be? ⏰\n\n" \
|
||||||
"(Enter the number of hours, e.g., 24 for last 24 hours, 168 for last week)"
|
"(Enter the number of hours, e.g., 24 for last 24 hours, 168 for last week)"
|
||||||
|
|
||||||
# JOB_AGE_MESSAGE: str = "Within how many hours do you want to see jobs posted? ⏰\n" \
|
# JOB_AGE_MESSAGE: str = "Within how many hours do you want to see jobs posted? ⏰\n" \
|
||||||
|
|
|
@ -53,14 +53,14 @@ class TelegramDefaultHandler(TelegramHandler):
|
||||||
|
|
||||||
site_names = [site.name for site in self.sites_to_scrap]
|
site_names = [site.name for site in self.sites_to_scrap]
|
||||||
site_names_print = ", ".join(site_names)
|
site_names_print = ", ".join(site_names)
|
||||||
# locations = [location + ", Israel" for location in user.cities]
|
locations = [location + f", {user.country}" for location in user.cities]
|
||||||
await self.telegram_bot.send_text(chat_id,
|
await self.telegram_bot.send_text(chat_id,
|
||||||
f"Start scarping: {site_names_print}")
|
f"Start scarping: {site_names_print}")
|
||||||
filtered_out_jobs, jobs = scrape_jobs(
|
filtered_out_jobs, jobs = scrape_jobs(
|
||||||
site_name=self.sites_to_scrap,
|
site_name=self.sites_to_scrap,
|
||||||
user=user,
|
user=user,
|
||||||
search_term=user.position.value,
|
search_term=user.position.value,
|
||||||
locations=user.cities,
|
locations=locations,
|
||||||
results_wanted=200,
|
results_wanted=200,
|
||||||
hours_old=int(user.job_age),
|
hours_old=int(user.job_age),
|
||||||
filter_by_title=user.title_filters,
|
filter_by_title=user.title_filters,
|
||||||
|
|
|
@ -142,8 +142,7 @@ class TelegramStartHandler:
|
||||||
cached_user: User = cache_manager.find(update.message.from_user.username)
|
cached_user: User = cache_manager.find(update.message.from_user.username)
|
||||||
cached_user.job_age = update.message.text
|
cached_user.job_age = update.message.text
|
||||||
cache_manager.save(cached_user.username, cached_user)
|
cache_manager.save(cached_user.username, cached_user)
|
||||||
await update.message.reply_text(
|
await update.message.reply_text(FILTER_TILE_MESSAGE)
|
||||||
FILTER_TILE_MESSAGE)
|
|
||||||
|
|
||||||
return Flow.FILTERS.value
|
return Flow.FILTERS.value
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue