diff --git a/Whatsapp_Chat_Exporter/__main__.py b/Whatsapp_Chat_Exporter/__main__.py index 54a90a0..95ccfc3 100644 --- a/Whatsapp_Chat_Exporter/__main__.py +++ b/Whatsapp_Chat_Exporter/__main__.py @@ -137,6 +137,10 @@ def setup_argument_parser() -> ArgumentParser: "--size", "--output-size", "--split", dest="size", nargs='?', const="0", default=None, help="Maximum (rough) size of a single output file in bytes, 0 for auto" ) + output_group.add_argument( + "--no-reply", dest="no_reply_ios", default=False, action='store_true', + help="Do not process replies (iOS only) (default: handle replies)" + ) # JSON formatting options json_group = parser.add_argument_group('JSON Options') @@ -554,8 +558,8 @@ def process_messages(args, data: ChatCollection) -> None: message_handler = ios_handler message_handler.messages( - db, data, args.media, args.timezone_offset, - args.filter_date, filter_chat, args.filter_empty + db, data, args.media, args.timezone_offset, args.filter_date, + filter_chat, args.filter_empty, args.no_reply_ios ) # Process media diff --git a/Whatsapp_Chat_Exporter/android_handler.py b/Whatsapp_Chat_Exporter/android_handler.py index 46e0511..45c73c8 100644 --- a/Whatsapp_Chat_Exporter/android_handler.py +++ b/Whatsapp_Chat_Exporter/android_handler.py @@ -57,7 +57,7 @@ def contacts(db, data, enrich_from_vcards): return True -def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat, filter_empty): +def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat, filter_empty, no_reply): """ Process WhatsApp messages from the database. @@ -669,7 +669,7 @@ def _process_single_media(data, content, media_folder, mime, separate_media): # Copy media to separate folder if needed if separate_media: chat_display_name = safe_name(current_chat.name or message.sender - or content["key_remote_jid"].split('@')[0]) + or content["key_remote_jid"].split('@')[0]) current_filename = file_path.split("/")[-1] new_folder = os.path.join(media_folder, "separated", chat_display_name) Path(new_folder).mkdir(parents=True, exist_ok=True) diff --git a/Whatsapp_Chat_Exporter/ios_handler.py b/Whatsapp_Chat_Exporter/ios_handler.py index 27aae7c..0501ac5 100644 --- a/Whatsapp_Chat_Exporter/ios_handler.py +++ b/Whatsapp_Chat_Exporter/ios_handler.py @@ -60,7 +60,7 @@ def get_contact_name(content): return content["ZPUSHNAME"] -def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat, filter_empty): +def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat, filter_empty, no_reply): """Process WhatsApp messages and contacts from the database.""" c = db.cursor() cursor2 = db.cursor() @@ -207,7 +207,7 @@ def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat, ) # Process message data - invalid = process_message_data(message, content, is_group_message, data, cursor2) + invalid = process_message_data(message, content, is_group_message, data, cursor2, no_reply) # Add valid messages to chat if not invalid: @@ -221,7 +221,7 @@ def messages(db, data, media_folder, timezone_offset, filter_date, filter_chat, logger.info(f"Processed {total_row_number} messages{CLEAR_LINE}") -def process_message_data(message, content, is_group_message, data, cursor2): +def process_message_data(message, content, is_group_message, data, cursor2, no_reply): """Process and set message data from content row.""" # Handle group sender info if is_group_message and content["ZISFROMME"] == 0: @@ -244,7 +244,7 @@ def process_message_data(message, content, is_group_message, data, cursor2): return process_metadata_message(message, content, is_group_message) # Handle quoted replies - if content["ZMETADATA"] is not None and content["ZMETADATA"].startswith(b"\x2a\x14"): + if content["ZMETADATA"] is not None and content["ZMETADATA"].startswith(b"\x2a\x14") and not no_reply: quoted = content["ZMETADATA"][2:19] message.reply = quoted.decode() cursor2.execute(f"""SELECT ZTEXT