feat: some more logs

This commit is contained in:
max_richter 2025-05-09 19:51:25 +02:00
parent a414a80766
commit 9dc01a59be
Signed by: max
GPG Key ID: 51973802EF3F77C5

View File

@ -39,6 +39,8 @@ bot.command("end", async (ctx) => {
const task = activeTasks[ctx.chat.id.toString()]; const task = activeTasks[ctx.chat.id.toString()];
if (!task) return ctx.reply("No active note found."); if (!task) return ctx.reply("No active note found.");
console.log("Ending note", task.noteName);
let finalNote = `# ${task.noteName}\n\n`; let finalNote = `# ${task.noteName}\n\n`;
const photoTasks: { content: Uint8Array; path: string }[] = []; const photoTasks: { content: Uint8Array; path: string }[] = [];
@ -49,19 +51,20 @@ bot.command("end", async (ctx) => {
finalNote += entry.content + "\n\n"; finalNote += entry.content + "\n\n";
} else if (entry.type === "voice") { } else if (entry.type === "voice") {
try { try {
console.log("Converting OGG to MP3");
const mp3Data = await convertOggToMp3(entry.content as Uint8Array); const mp3Data = await convertOggToMp3(entry.content as Uint8Array);
console.log("Finished converting OGG to MP3, transcribing...");
const transcript = await transcribe(mp3Data); const transcript = await transcribe(mp3Data);
finalNote += `**Voice Transcript:**\n${transcript}\n\n`; finalNote += `**Voice Transcript:**\n${transcript}\n\n`;
console.log("Finished transcribing");
} catch (error) { } catch (error) {
console.log(error); console.log(error);
finalNote += "**[Voice message could not be transcribed]**\n\n"; finalNote += "**[Voice message could not be transcribed]**\n\n";
} }
} else if (entry.type === "photo") { } else if (entry.type === "photo") {
photoIndex++;
const photoUrl = `${ const photoUrl = `${
task.noteName.replace(/\.md$/, "") task.noteName.replace(/\.md$/, "")
}/photo-${photoIndex}.jpg`; }/photo-${photoIndex++}.jpg`;
finalNote += `**Photo**:\n ${photoUrl}\n\n`; finalNote += `**Photo**:\n ${photoUrl}\n\n`;
photoTasks.push({ photoTasks.push({
@ -84,9 +87,9 @@ bot.command("end", async (ctx) => {
await ctx.reply("Error creating document:"); await ctx.reply("Error creating document:");
if (error instanceof Error) { if (error instanceof Error) {
await ctx.reply(error?.toString()); await ctx.reply(error?.toString());
}else if (error instanceof Response) { } else if (error instanceof Response) {
await ctx.reply(error?.statusText); await ctx.reply(error?.statusText);
}else if (typeof error === "string") { } else if (typeof error === "string") {
await ctx.reply(error); await ctx.reply(error);
} }
} }