diff --git a/bin/.bin/checkworkmail.py b/bin/.bin/checkworkmail.py index aef8f65..5991bc3 100755 --- a/bin/.bin/checkworkmail.py +++ b/bin/.bin/checkworkmail.py @@ -58,6 +58,27 @@ def extract_body(msg): return payload return "(No readable body content found)" +def clean_slack_body(body): + # Remove intro like: "Hi Colin,\n\nYou have a new direct message from ..." + cleaned = re.sub( + r"Hi .*?,\s+You have a new direct message from.*?\(.*?\.slack\.com.*?\)\.\s+---", + "", + body, + flags=re.DOTALL, + ) + return cleaned.strip() + +def clean_slack_body(body): + # Remove intro like: "Hi Colin,\n\nYou have a new direct message from ..." + cleaned = re.sub( + r"Hi .*?,\s+You have a new direct message from.*?\(.*?\.slack\.com.*?\)\.\s+---", + "", + body, + flags=re.DOTALL, + ) + return cleaned.strip() + + def extract_github_link(subject, body): pr_match = re.search(r'\(PR\s+#(\d+)\)', subject) repo_match = re.search(r'\[([^\]]+)\]', subject) # [owner/repo] @@ -136,6 +157,7 @@ def check_notifications(): elif is_slack_email(from_email, subject): source = "Slack" link = "" + body = clean_slack_body(body) else: print(f"Skipping non-matching email: {subject}") continue