Open ristomatti opened 1 month ago
Thanks you for creating this, I was able to recover an important chat thanks to it! 🙏
However, I ran across an issue. After importing the chat, I noticed the resulting chat history had all the messages "sent" by the other person. The messages included the original senders name, so it could've been a lot better than no history at all. I had no idea if this is to be expected or not. I then read Telegram's blog post of the import feature. The illustrative video of exporting from WhatsApp seemed to indicate the result should show the imported messages like a normal conversation (just have the text "imported" on each message).
I then tried exporting a chat with the same person from WhatsApp. The end result was just like on the demo video. I then exported the WhatsApp chat again but into a zip file and checked how it differs.
The resulting
_chat.txt
after running the Python script had this format:[2022/01/11, 16:53:27] - Alice: Hi Bob! [2022/01/12, 20:26:40] - Bob: Hi!
The chat exported from WhatsApp was the same except without the square brackets or seconds. It also had the full name instead of just the firstname:
2022/01/11, 16:53 - Alice Doe: Hi Bob! 2022/01/12, 20:26 - Bob Smith: Hi!
Another difference was that the resulting zip file was
WhatsApp Chat with Alice Doe.zip
and the text file was named`WhatsApp Chat with Alice Doe.txt
.I then tried removed the square brackets and changed the names to include the lastname in the
_chat.txt
generated by the script. I left the seconds in the timestamps intact. I also renamed the text file and the zip file to match the one I exported from WhatsApp. When I imported this to Telegram, the chat history came out perfect. 😅Before testing with WhatsApp, I tried adding the lastname of both participants but it didn't work any better. I didn't test if it was removing the square brackets or naming the
txt
differently that did the trick though. It's also possible I made some error when initially trying if just changing the names would help.
Hi, internet stranger here, hope this helps. Had the same bug today when trying to import a chat. The bug is at line 37 and 41
# Prepare the message in a WhatsApp-like format
whatsapp_message = f"{date} - {from_user}: {text}\n"
# Handle non-string messages (e.g., media messages)
if not isinstance(text, str):
whatsapp_message = f"{date} - {from_user}: <Media omitted>\n"
Basically, if you look at a real Whatsapp export, there is no -
, at least in single chats.
Pulling a rabbit out of my dev hat here, but I think this was intended to make it work with groups and multiple users, but it actually breaks single chat exports. It should either be a flag in the args or the script should auto detect the number of partecipants.
Everything worked flawlessly once I removed it. I'm on iOS if it helps.
Have a nice evening
Thanks you for creating this, I was able to recover an important chat thanks to it! :pray:
However, I ran across an issue. After importing the chat, I noticed the resulting chat history had all the messages "sent" by the other person. The messages included the original senders name, so it could've been a lot better than no history at all. I had no idea if this is to be expected or not. I then read Telegram's blog post of the import feature. The illustrative video of exporting from WhatsApp seemed to indicate the result should show the imported messages like a normal conversation (just have the text "imported" on each message).
I then tried exporting a chat with the same person from WhatsApp. The end result was just like on the demo video. I then exported the WhatsApp chat again but into a zip file and checked how it differs.
The resulting
_chat.txt
after running the Python script had this format:The chat exported from WhatsApp was the same except without the square brackets or seconds. It also had the full name instead of just the firstname:
Another difference was that the resulting zip file was
WhatsApp Chat with Alice Doe.zip
and the text file was named`WhatsApp Chat with Alice Doe.txt
.I then tried removed the square brackets and changed the names to include the lastname in the
_chat.txt
generated by the script. I left the seconds in the timestamps intact. I also renamed the text file and the zip file to match the one I exported from WhatsApp. When I imported this to Telegram, the chat history came out perfect. :sweat_smile:Before testing with WhatsApp, I tried adding the lastname of both participants but it didn't work any better. I didn't test if it was removing the square brackets or naming the
txt
differently that did the trick though. It's also possible I made some error when initially trying if just changing the names would help.