Suberbia / UltimateChatRestorer

A tool for converting Telegram chat exports into a WhatsApp-compatible format. This script transforms JSON exports from Telegram into a plain text format that mirrors WhatsApp’s chat layout, making it easier to import chats back into Telegram or for use in other applications.
MIT License
47 stars 4 forks source link

empty _chat.txt output #2

Open Lucasquattro opened 2 months ago

Lucasquattro commented 2 months ago

Hi there, I tried the script but unfortunately the output is an empty _chat.txt file. I tried with different json output and tried also to simplify to a single message to understand if n° messages was a limit. Nothing changed.

I'm on mac, python3 and brew all updated to last versions, idk where I miss something. Below example of json used:

{
    "about": "Here is the data you requested. Remember: Telegram is ad free, it doesn't use your data for ad targeting and doesn't sell it to others. Telegram only keeps the information it needs to function as a secure and feature-rich cloud service.\n\nCheck out Settings > Privacy & Security on Telegram's mobile apps for the relevant settings.",
    "chats": {
        "about": "This page lists all chats from this export.",
        "list": [
            {
                "name": "testuser",
                "type": "personal_chat",
                "id": 1111111111,
                "messages": [
                    {
                        "id": 740140,
                        "type": "message",
                        "date": "2024-02-06T14:13:29",
                        "date_unixtime": "1707225209",
                        "from": "testuser",
                        "from_id": "user1111111111",
                        "text": "test test",
                        "text_entities": [
                            {
                                "type": "plain",
                                "text": "test test"
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

Many thanks!

Suberbia commented 3 weeks ago

Subject: Update on the Telegram to WhatsApp Chat Converter Script

Hey Lucasquattro,

Thanks for letting me know about the issue with the script producing a blank _chat.txt file. I took a closer look, and it turns out the problem was due to a difference in how the Telegram export JSON was structured.

What Happened:

The script was originally set up to work with Telegram exports where the messages were right at the root of the JSON file. But in your export, the messages were actually nested under chats -> list -> [0]. Because of this, the script couldn’t find the messages and ended up generating an empty file.

The Fix:

I’ve updated the script to handle this kind of nested structure. Now, it checks for messages both at the root level and within the chats section, so it should work no matter where the messages are located in your export file.

What to Do Next:

Go ahead and try running the updated script with your Telegram export. It should now create the _chat.txt file with all your chat content formatted for WhatsApp.

I really appreciate you pointing this out, and I hope this fix does the trick. If you run into any other issues or have more feedback, just let me know.

Cheers,
Suberbia