tvdstaaij / telegram-history-dump

Backup Telegram chat logs using telegram-cli
Other
663 stars 85 forks source link

Sometimes last message is dumped again #35

Open giomasce opened 8 years ago

giomasce commented 8 years ago

The tool is working great, except for a small bug: for some chats at every execution of telegram-history-dump the last message is added again to the jsonl file (and therefore to the other formatters). For example:

{"event":"message","unread":false,"out":false,"text":"Такой статьи у меня в базе пока нет!\nI don't have this article in database yet","id":"010000004bebb509376a0000000000004c0bdeeeb86ea71d","flags":256,"from":{"first_name":"Sci-Hub","id":"$010000004bebb5094c0bdeeeb86ea71d","username":"scihubot","peer_type":"user","peer_id":162917195,"print_name":"Sci-Hub","flags":1,"last_name":""},"to":{"id":"$010000005fd382005407330023a867ff","first_name":"Giovanni","username":"giomasce","peer_type":"user","peer_id":8573791,"print_name":"Giovanni_Mascellani","flags":524289,"when":"2016-08-02 22:30:57","last_name":"Mascellani","phone":"[omitted]"},"service":false,"date":1470169330}
{"event":"message","unread":false,"out":false,"text":"Такой статьи у меня в базе пока нет!\nI don't have this article in database yet","id":"010000004bebb509376a0000000000004c0bdeeeb86ea71d","flags":256,"from":{"first_name":"Sci-Hub","id":"$010000004bebb5094c0bdeeeb86ea71d","username":"scihubot","peer_type":"user","peer_id":162917195,"print_name":"Sci-Hub","flags":1,"last_name":""},"to":{"id":"$010000005fd382005407330023a867ff","first_name":"Giovanni","username":"giomasce","peer_type":"user","peer_id":8573791,"print_name":"Giovanni_Mascellani","flags":524289,"when":"2016-08-02 22:27:21","last_name":"Mascellani","phone":"[omitted]"},"service":false,"date":1470169330}

At each execution, another similar row will be added to the top of the file. It happens with just a few chats, maybe one or two of the dozens I have. I cannot see any patter: I used to think that only happened when the last message was an attachment, but the example above disproves that.

tvdstaaij commented 7 years ago

It's hard to tell what causes this from this data alone (the surrounding messages could help), but since you opened this issue I thought that it was probably because of my workaround for vysheng/tg#1077. I did some digging in the telegram-cli code, and based on my findings I developed a new workaround that should be more reliable, which is now on master.

giomasce commented 7 years ago

It now seems to be working correctly. I'll let my script run for a few days and then I'll confirm. Thanks.