Some messages are unsupported by some versions of Telegram, which caused the following error when running the script.
Traceback (most recent call last):
File "/tmp/TelegramChatStats/./telegram-statistics.py", line 196, in <module>
main()
File "/tmp/TelegramChatStats/./telegram-statistics.py", line 177, in main
raw = calculate_graphs(chat_data, date_filter, wordlist)
File "/tmp/TelegramChatStats/./telegram-statistics.py", line 118, in calculate_graphs
return _message_graphs(chat_data, date_filter, wordlist)
File "/tmp/TelegramChatStats/_message_graphs.py", line 171, in _message_graphs
metrics = _parse_chat(chat, date_filter, wordlist)
File "/tmp/TelegramChatStats/_message_graphs.py", line 69, in _parse_chat
date_obj = datetime.strptime(message['date'], '%Y-%m-%dT%H:%M:%S')
KeyError: 'date'
The structure of a unsupported message is similar to this:
{'id': 43178, 'type': 'unsupported'}
Therefore I add an if statement at the top of the for loop to check if the type of this message is 'unsupported'; if yes, skip this message.
Some messages are unsupported by some versions of Telegram, which caused the following error when running the script.
The structure of a unsupported message is similar to this:
Therefore I add an if statement at the top of the for loop to check if the type of this message is 'unsupported'; if yes, skip this message.