From a4318aca8970ff47875e87516713c4848b341b95 Mon Sep 17 00:00:00 2001 From: lifnej <235678045+lifnej@users.noreply.github.com> Date: Thu, 2 Oct 2025 14:26:55 +0200 Subject: [PATCH] Enrich numbers with vcard names in group chats. --- Whatsapp_Chat_Exporter/vcards_contacts.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Whatsapp_Chat_Exporter/vcards_contacts.py b/Whatsapp_Chat_Exporter/vcards_contacts.py index 18cd500..fc2d77d 100644 --- a/Whatsapp_Chat_Exporter/vcards_contacts.py +++ b/Whatsapp_Chat_Exporter/vcards_contacts.py @@ -27,6 +27,14 @@ class ContactsFromVCards: if not hasattr(chat, 'name') or (hasattr(chat, 'name') and (chat.name is None or chat.name == '')): setattr(chat, 'name', name) + # skip short numbers like above + contact_map = {number: name for number, name in self.contact_mapping if len(number) > 5} + + # replace all sender number in chats with vcf name if available + for chat in chats.values(): + for message in chat.values(): # or {}: + if message.sender and message.sender in contact_map: + message.sender = contact_map[message.sender] def read_vcards_file(vcf_file_path, default_country_code: str): contacts = []