function parseZoomChat(transcript) {
const messageBlocks = transcript.split(/(?=\d{2}:\d{2}:\d{2} From )/);
const messages = [];
let idCounter = 0;
messageBlocks.forEach(block => {
if (!block.trim()) return;
const headerPattern = /^(\d{2}:\d{2}:\d{2}) From (.*?) to Everyone:/;
const headerMatch = block.match(headerPattern);
if (headerMatch) {
const timestamp = headerMatch[1];
const sender = headerMatch[2];
const contentStart = block.indexOf("Everyone:") + "Everyone:".length;
const contentBlock = block.substring(contentStart).trim().replace(/\\r\\n\\t/g, "\n");
const lines = contentBlock.split("\n").map(line => line.trim()).filter(line => line);
const message = {
id: idCounter++,
timestamp,
sender,
content: lines[0],
replyTo: null
};
if (lines.length > 1 && lines[0].startsWith("Replying to")) {
const replyMatch = lines[0].match(/Replying to "(.*?)"/);
if (replyMatch) {
message.replyTo = replyMatch[1];
message.content = lines.slice(1).join(" ");
}
} else {
message.content = lines.join(" ");
}
if (lines[0].startsWith("Reacted to")) {
const reactionMatch = lines[0].match(/Reacted to "(.*?)" with (.*)/);
if (reactionMatch) {
message.reactionTo = reactionMatch[1];
message.emoji = reactionMatch[2];
message.content = `Reacted to "${reactionMatch[1]}" with ${reactionMatch[2]}`;
}
}
messages.push(message);
}
});
messages.forEach(message => {
if (message.replyTo || message.reactionTo) {
let searchContent = message.replyTo || message.reactionTo;
searchContent = searchContent.replace("...", "")
searchContent = searchContent.replace("…", "")
const parentMessage = messages.find(m => m.content.indexOf(searchContent) == 0);
if (parentMessage) {
message.parentId = parentMessage.id;
}
}
});
return messages;
}