Skip to content

Commit

Permalink
improve messages from bot, recognize CVs
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Apr 16, 2024
1 parent 4a05d5d commit 290e5ec
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
49 changes: 41 additions & 8 deletions jg/chick/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
)
from jg.chick.lib.reviews import (
GITHUB_API_KEY,
REVIEWER_ROLE_ID,
find_cv_url,
find_github_url,
find_linkedin_url,
format_summary,
Expand Down Expand Up @@ -198,11 +200,31 @@ async def handle_candidate_thread(
async def handle_review_thread(
starting_message: discord.Message, thread: discord.Thread
):
if cv_url := find_cv_url(starting_message.attachments):
logger.info(f"Found CV in {thread.name!r}, reviewing…")
await starting_message.add_reaction("🔬")
await starting_message.reply(
(
"📝 Zavětřilo jsem CV"
"\n\n"
"🙏 Na CV zatím zpětnou vazbu dávat neumím, ale třeba pomůže někdo jiný"
"\n\n"
"💡 Přečti si [návod na CV](https://junior.guru/handbook/cv/) v příručce, ušetříš spoustu času sobě i nám! "
"Ve zpětné vazbě nebudeme muset opakovat rady z návodu a budeme se moci soustředit na to podstatné."
),
suppress=True,
)
await add_members_with_role(thread, REVIEWER_ROLE_ID)

if github_url := find_github_url(starting_message.content):
logger.info(f"Found {github_url} in {thread.name!r}, reviewing…")
await starting_message.add_reaction("🔬")
await starting_message.reply(
f"<:github:842685206095724554> Zavětřilo jsem GitHub profil {github_url}, jdu se v tom pohrabat…",
(
f"<:github:842685206095724554> Zavětřilo jsem [GitHub profil]({github_url}), jdu se v tom pohrabat…"
"\n\n"
"💡 Přečti si [návod na GitHub profil](https://junior.guru/handbook/github-profile/) v příručce, pochopíš kontext mých doporučení."
),
suppress=True,
)
async with thread.typing():
Expand All @@ -218,20 +240,31 @@ async def handle_review_thread(
await starting_message.add_reaction("🔬")
await starting_message.reply(
(
f"<:linkedin:915267970752712734> Zavětřilo jsem LinkedIn profil {linkedin_url}\n\n"
"Na LinkedIn zatím zpětnou vazbu dávat neumím, ale třeba pomůže někdo jiný 🙏"
f"<:linkedin:915267970752712734> Zavětřilo jsem [LinkedIn profil]({linkedin_url})"
"\n\n"
"🙏 Na LinkedIn zatím zpětnou vazbu dávat neumím, ale třeba pomůže někdo jiný"
"\n\n"
"💡 Přidej se do [naší LinkedIn skupiny](https://www.linkedin.com/groups/13988090/). "
"Můžeš se pak snadno propojit s ostatními členy a oni s tebou. "
"Zároveň se ti bude logo junior.guru zobrazovat na profilu v sekci „zájmy”. "
"Nevíme, jestli ti to přidá nějaký kredit u recruiterů, ale vyloučeno to není!"
),
suppress=True,
)

tags = prepare_tags(thread, github=bool(github_url), linkedin=bool(linkedin_url))
await thread.edit(applied_tags=tags)
await add_members_with_role(thread, REVIEWER_ROLE_ID)

await thread.edit(
applied_tags=prepare_tags(
thread,
cv=bool(cv_url),
github=bool(github_url),
linkedin=bool(linkedin_url),
)
)

if not github_url and not linkedin_url:
await starting_message.reply(
"Nenašlo jsem žádný GitHub ani LinkedIn profil. "
"Pokud nějaký máš a chceš jej zkontrolovat, přidej sem zprávu, "
"ve které mě označíš a bude v ní odkaz na ten profil."
)

# await add_members_with_role(thread, REVIEWER_ROLE_ID)
9 changes: 8 additions & 1 deletion jg/chick/lib/reviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any, Generator, TypedDict
from urllib.parse import quote, unquote

from discord import Color, Embed, ForumTag, Thread
from discord import Attachment, Color, Embed, ForumTag, Thread
from jg.hen.core import ResultType, Summary


Expand All @@ -25,6 +25,13 @@
}


def find_cv_url(attachments: list[Attachment]) -> str | None:
for attachment in attachments:
if attachment.content_type == "application/pdf":
return attachment.url
return None


def find_github_url(text: str) -> str | None:
if match := GITHUB_URL_RE.search(text):
username = match.group("username")
Expand Down

0 comments on commit 290e5ec

Please sign in to comment.