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