ToonTownTommy's picture
remove messages like missed your call, called you., Reacted 😆 to your message, You set the quick reaction to 🤣, remove any blank messages, the apostrophes are messed up so fix those, add an inforrgraph about the conversation like total messages per person emojis sent, if multiple json are uploaded merge them
d295941 verified
Raw History Blame Contribute Delete
967 Bytes
function generateConversationStats(data) {
const stats = {
totalMessages: data.messages.length,
messagesBySender: {},
emojiUsage: {},
topEmojis: {}
};
// Count messages by sender
data.messages.forEach(msg => {
if (msg.sender_name) {
stats.messagesBySender[msg.sender_name] =
(stats.messagesBySender[msg.sender_name] || 0) + 1;
}
// Count emoji usage
if (msg.content) {
const emojiRegex = /[\p{Emoji}]/gu;
const emojis = msg.content.match(emojiRegex) || [];
emojis.forEach(emoji => {
stats.emojiUsage[emoji] = (stats.emojiUsage[emoji] || 0) + 1;
});
}
});
// Sort and get top 10 emojis
stats.topEmojis = Object.fromEntries(
Object.entries(stats.emojiUsage)
.sort((a, b) => b[1] - a[1])
.slice(0, 10)
);
return stats;
}