Skip to content

Commit 2e07c04

Browse files
authored
Merge pull request #8 from swecc-uw/navneeth
Added a check to see if a user was verified or not + better edge case process logging
2 parents 7b28cd0 + bd405dc commit 2e07c04

3 files changed

Lines changed: 60 additions & 12 deletions

File tree

services/bot/APIs/GeminiAPI.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ async def process_timeline_message(self, timeline, is_authorized, user):
250250
3. If it **does**, return the timeline **exactly as it appears in the text**, preserving dates, formatting, and stage names.
251251
4. Do **not** modify or normalize dates, add placeholders, or change event names.
252252
5. Do **not** include any extra text, explanations, or filler.
253+
6. A valid job application timeline must list each stage on its own line with the date. Sentences or paragraphs do NOT count as valid timelines.
253254
254255
### Example (relevant timeline)
255256
Got reachout 10/10

services/bot/slash_commands/auth.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ async def register(ctx: discord.Interaction):
113113
await ctx.response.send_message(usr_msg, ephemeral=True)
114114
await bot_context.log(ctx, sys_msg)
115115
elif role is None:
116-
usr_msg = f"Something went wrong. Please contact an admin."
116+
usr_msg = f"Something went wrong. Please contact an officer."
117117
sys_msg = f"ERROR: Role {verified_rid} not found, skipping registration for {ctx.user.display_name}"
118118

119119
await ctx.response.send_message(usr_msg, ephemeral=True)
@@ -177,11 +177,25 @@ async def on_error(self, interaction: discord.Interaction, error: Exception):
177177

178178

179179
async def auth(ctx: discord.Interaction):
180-
await ctx.response.send_modal(
181-
VerifyModal(
182-
bot_context,
180+
verified_rid = bot_context.verified_role_id
181+
if (role := ctx.guild.get_role(verified_rid)) and role in ctx.user.roles:
182+
usr_msg = f"You are already verified"
183+
sys_msg = f"{ctx.user.display_name} has tried to verify but is already verified."
184+
await ctx.response.send_message(usr_msg, ephemeral=True)
185+
await bot_context.log(ctx, sys_msg)
186+
elif role is None:
187+
usr_msg = f"Something went wrong. Please contact an officer."
188+
sys_msg = f"ERROR: Role {verified_rid} not found, skipping verification for {ctx.user.display_name}"
189+
190+
await ctx.response.send_message(usr_msg, ephemeral=True)
191+
await bot_context.log(ctx, sys_msg)
192+
else:
193+
await ctx.user.add_roles(role)
194+
await ctx.response.send_modal(
195+
VerifyModal(
196+
bot_context,
197+
)
183198
)
184-
)
185199

186200

187201
async def reset_password(ctx: discord.Interaction):

services/bot/slash_commands/misc.py

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def __init__(self, bot_context, is_authorized, username, bot):
480480
self.timeline = discord.ui.TextInput(
481481
label="Timeline",
482482
style=discord.TextStyle.long,
483-
placeholder="Enter process timeline",
483+
placeholder="Enter timeline: Reachout 10/10, R1 11/10, R2 15/10, Offer 25/10",
484484
required=True,
485485
)
486486

@@ -497,16 +497,48 @@ async def on_submit(self, interaction):
497497

498498
processed_timeline = await gemini_api.process_timeline_message(
499499
timeline, self.is_authorized, self.username
500-
) # pass only the timeline
500+
)
501+
502+
not_relevant = "Not relevant"
503+
failed_request = "Request failed. Please try again later."
504+
error = "Error occurred Please try again later."
501505

502506
if not TIMELINE_CHANNEL:
503507
await interaction.followup.send("Timeline feature is not configured.", ephemeral=True)
504508
return
505509

506510
channel = self.bot.get_channel(TIMELINE_CHANNEL)
507511

508-
if processed_timeline == "Not relevant":
509-
await interaction.followup.send("Your description was not relevant!", ephemeral=True)
512+
sys_msg = None
513+
514+
if processed_timeline == not_relevant:
515+
await interaction.followup.send(
516+
"Your description was not relevant!",
517+
ephemeral=True,
518+
)
519+
sys_msg = f"{self.username} has tried to add a process timeline for a company but the description was not relevant. Original timeline: {timeline}."
520+
elif processed_timeline == failed_request:
521+
await interaction.followup.send(
522+
"Request failed. Please try again later.",
523+
ephemeral=True,
524+
)
525+
sys_msg = f"{self.username} has tried to add a process timeline for a company but the Gemini request failed. Oringinal timeline: {timeline}. Processed timeline: {processed_timeline}."
526+
527+
elif processed_timeline == error:
528+
await interaction.followup.send(
529+
"Error occurred. Please try again later.",
530+
ephemeral=True,
531+
)
532+
sys_msg = f"{self.username} has tried to add a process timeline for a company but an error occurred. Original timeline: {timeline}. Processed timeline: {processed_timeline}."
533+
534+
elif processed_timeline != timeline:
535+
await interaction.followup.send(
536+
"Processing failed. Please try again later.", ephemeral=True
537+
)
538+
sys_msg = f"{self.username} has tried to add a process timeline for a company but the processed output was not the timeline. Original timeline: {timeline}. Processed timeline: {processed_timeline}."
539+
540+
if sys_msg:
541+
await self.bot_context.log(interaction, sys_msg)
510542
return
511543

512544
embed = discord.Embed(title=f"Process for {company_name}", color=discord.Color.blue())
@@ -518,11 +550,13 @@ async def on_submit(self, interaction):
518550

519551
await interaction.followup.send("Your process timeline was submitted!", ephemeral=True)
520552

553+
sys_msg = f"{self.username} has added a process timeline for a company. Processed timeline: {processed_timeline}, Original timeline: {timeline}."
554+
await self.bot_context.log(interaction, sys_msg)
555+
521556

522557
async def process(ctx: discord.Interaction):
523558
verified_rid = bot_context.verified_role_id
524559
if (role := ctx.guild.get_role(verified_rid)) and role in ctx.user.roles:
525-
sys_msg = f"{ctx.user.display_name} has tried to add a process timeline for a company."
526560
await ctx.response.send_modal(
527561
ProcessModal(
528562
bot_context,
@@ -531,11 +565,10 @@ async def process(ctx: discord.Interaction):
531565
bot=ctx.client,
532566
)
533567
)
534-
await bot_context.log(ctx, sys_msg)
535568
else:
536569
usr_msg = f"You are not verified. Please use /verify to be able to add a process timeline."
537570
sys_msg = (
538-
f"ERROR: {ctx.user.display_name} not verified and tried to add a process timeline."
571+
f"ERROR: {ctx.user.display_name} is not verified and tried to add a process timeline."
539572
)
540573

541574
await ctx.response.send_message(usr_msg, ephemeral=True)

0 commit comments

Comments
 (0)