mirror of https://github.com/Bunsly/JobSpy
added step and updated some messages
parent
f400c6eee7
commit
6e841ffc22
src/telegram_handler
|
@ -1,4 +1,4 @@
|
|||
START_MESSAGE: str = "Hi there! I'm Professor Bot, your friendly job search assistant.😊\n" \
|
||||
START_MESSAGE: str = "Hi there! I'm JobSeeker Bot, your friendly job search assistant.😊\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"
|
||||
|
||||
|
@ -7,20 +7,29 @@ POSITION_MESSAGE: str = "What kind of position are you looking for? ✨\n" \
|
|||
|
||||
POSITION_NOT_FOUND: str = "I couldn't find any positions matching your request. 😕\n" \
|
||||
"Please try again"
|
||||
multi_value_message: str = "📌 You can enter multiple tags separated by commas."
|
||||
multi_value_message: str = "Enter multiple values separated by commas (e.g., value1, value2, value3) ✍️"
|
||||
|
||||
LOCATION_MESSAGE: str = "Where are you hoping to find a position? 🌎\n" \
|
||||
"(e.g., Rishon Lezion, New York City, San Francisco)\n\n" + multi_value_message
|
||||
|
||||
EXPERIENCE_MESSAGE: str = "How many years of professional experience do you have in this field? 💼\n"
|
||||
|
||||
EXPERIENCE_INVALID: str = "Experience must be a number. 😕\n" \
|
||||
"Please try again"
|
||||
EXPERIENCE_INVALID: str = "Oops! Please enter your experience in years as a number.😕" \
|
||||
"For example, 2, 5, or 10."
|
||||
|
||||
JOB_AGE_MESSAGE: str = "How recent should the jobs be? ⏰\n" \
|
||||
"(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" \
|
||||
# "(Enter a number, e.g., 48 for the last 48 hours)"
|
||||
|
||||
JOB_AGE_INVALID: str = "Oops! Please enter a number for the number of hours. 😕\n" \
|
||||
"For example, 24, 48, or 168."
|
||||
|
||||
FILTER_TILE_MESSAGE: str = "To help me narrow down your search, tell me about any relevant tags or keywords.\n" \
|
||||
"For example: 'remote', 'entry-level', 'python', 'machine learning', 'QA'.\n\n" + multi_value_message
|
||||
|
||||
THANK_YOU_MESSAGE: str = "Thank you for chatting with Professor Bot!\n\n" \
|
||||
THANK_YOU_MESSAGE: str = "Thank you for chatting with JobSeeker Bot!\n\n" \
|
||||
"I can help you find jobs on LinkedIn, Glassdoor, and more."
|
||||
|
||||
SEARCH_MESSAGE: str = "To search for jobs on a specific site, simply send the site name:\n" \
|
||||
|
|
|
@ -25,6 +25,7 @@ class Flow(Enum):
|
|||
VERIFY_ADDRESS = 4
|
||||
VERIFY_FILTERS = 5
|
||||
SKIP_FILTERS = 6
|
||||
JOB_AGE = 7
|
||||
|
||||
|
||||
class TelegramStartHandler:
|
||||
|
@ -57,9 +58,9 @@ class TelegramStartHandler:
|
|||
"""Stores the selected position and asks for a locations."""
|
||||
user = update.message.from_user
|
||||
self.logger.info("Position of %s: %s", user.first_name, update.message.text)
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
position = next((p for p in Position if p.value == update.message.text), None)
|
||||
if not position:
|
||||
await update.message.set_reaction(ReactionEmoji.PILE_OF_POO)
|
||||
await update.message.reply_text(POSITION_NOT_FOUND)
|
||||
buttons = [[KeyboardButton(position.value)] for position in Position]
|
||||
reply_markup = ReplyKeyboardMarkup(buttons, one_time_keyboard=True,
|
||||
|
@ -69,6 +70,8 @@ class TelegramStartHandler:
|
|||
reply_markup=reply_markup,
|
||||
)
|
||||
return Flow.POSITION.value
|
||||
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
cached_user: User = cache_manager.find(user.username)
|
||||
cached_user.position = position
|
||||
cache_manager.save(cached_user.username, cached_user)
|
||||
|
@ -94,32 +97,55 @@ class TelegramStartHandler:
|
|||
|
||||
async def verify_address(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||
"""Verify for a Address."""
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
if update.message.text == "No":
|
||||
await update.message.set_reaction(ReactionEmoji.PILE_OF_POO)
|
||||
await update.message.reply_text(LOCATION_MESSAGE)
|
||||
return Flow.ADDRESS.value
|
||||
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
await update.message.reply_text(EXPERIENCE_MESSAGE)
|
||||
|
||||
return Flow.EXPERIENCE.value
|
||||
|
||||
async def experience(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||
"""Asks for a experience."""
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
user = update.message.from_user
|
||||
self.logger.info("Experience of %s: %s", user.first_name, update.message.text)
|
||||
|
||||
if not update.message.text.isnumeric():
|
||||
await update.message.set_reaction(ReactionEmoji.PILE_OF_POO)
|
||||
await update.message.reply_text(EXPERIENCE_INVALID)
|
||||
await update.message.reply_text(EXPERIENCE_MESSAGE)
|
||||
|
||||
return Flow.EXPERIENCE.value
|
||||
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
cached_user: User = cache_manager.find(update.message.from_user.username)
|
||||
cached_user.experience = update.message.text
|
||||
cache_manager.save(cached_user.username, cached_user)
|
||||
await update.message.reply_text(
|
||||
FILTER_TILE_MESSAGE)
|
||||
return Flow.JOB_AGE.value
|
||||
|
||||
async def job_age(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||
"""Asks for a Job age in hours."""
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
user = update.message.from_user
|
||||
self.logger.info("Job age of %s: %s", user.first_name, update.message.text)
|
||||
|
||||
if not update.message.text.isnumeric():
|
||||
await update.message.set_reaction(ReactionEmoji.PILE_OF_POO)
|
||||
await update.message.reply_text(EXPERIENCE_INVALID)
|
||||
await update.message.reply_text(EXPERIENCE_MESSAGE)
|
||||
|
||||
return Flow.EXPERIENCE.value
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
cached_user: User = cache_manager.find(update.message.from_user.username)
|
||||
cached_user.experience = update.message.text
|
||||
cache_manager.save(cached_user.username, cached_user)
|
||||
await update.message.reply_text(
|
||||
FILTER_TILE_MESSAGE)
|
||||
|
||||
return Flow.FILTERS.value
|
||||
|
||||
async def filters_flow(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||
|
@ -138,11 +164,12 @@ class TelegramStartHandler:
|
|||
|
||||
async def verify_filter(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||
"""Verify for a filters_flow."""
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
if update.message.text == "No":
|
||||
await update.message.set_reaction(ReactionEmoji.PILE_OF_POO)
|
||||
await update.message.reply_text(FILTER_TILE_MESSAGE)
|
||||
return Flow.FILTERS.value
|
||||
|
||||
await update.message.set_reaction(ReactionEmoji.FIRE)
|
||||
await update.message.reply_text(THANK_YOU_MESSAGE)
|
||||
await update.message.reply_text(SEARCH_MESSAGE)
|
||||
cached_user: User = cache_manager.find(update.message.from_user.username)
|
||||
|
@ -180,6 +207,7 @@ start_conv_handler = ConversationHandler(
|
|||
Flow.ADDRESS.value: [MessageHandler(filters.TEXT, start_handler.address)],
|
||||
Flow.VERIFY_ADDRESS.value: [MessageHandler(filters.TEXT, start_handler.verify_address)],
|
||||
Flow.EXPERIENCE.value: [MessageHandler(filters.TEXT, start_handler.experience)],
|
||||
Flow.JOB_AGE.value: [MessageHandler(filters.TEXT, start_handler.job_age)],
|
||||
Flow.FILTERS.value: [MessageHandler(filters.TEXT, start_handler.filters_flow)],
|
||||
Flow.VERIFY_FILTERS.value: [MessageHandler(filters.TEXT, start_handler.verify_filter)],
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue