From 34077c68189bcc21490db05fae5c2228369f0f39 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Sat, 5 Oct 2024 16:09:04 -0700 Subject: [PATCH] betterUserDetection --- etc/report_generator.py | 5 ++++- etc/report_generator5.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/etc/report_generator.py b/etc/report_generator.py index b5974ab..30ed0ba 100644 --- a/etc/report_generator.py +++ b/etc/report_generator.py @@ -151,7 +151,10 @@ def parse_log_file(file_path): log_data['shameList'].insert(0, line) # get the user who sent the message - user_match = re.search(r'From: (\w+)', line) + if 'To: ' in line: + user_match = re.search(r"From: '([^']+)'(?: To:|$)", line) + else: + user_match = re.search(r"From: (.+)$", line) if user_match: log_data['unique_users'].add(user_match.group(1)) diff --git a/etc/report_generator5.py b/etc/report_generator5.py index 43440a1..ad8f1b4 100644 --- a/etc/report_generator5.py +++ b/etc/report_generator5.py @@ -160,7 +160,10 @@ def parse_log_file(file_path): log_data['shameList'].insert(0, line) # get the user who sent the message - user_match = re.search(r'From: (\w+)', line) + if 'To: ' in line: + user_match = re.search(r"From: '([^']+)'(?: To:|$)", line) + else: + user_match = re.search(r"From: (.+)$", line) if user_match: log_data['unique_users'].add(user_match.group(1))