diff --git a/lib/telegram.ts b/lib/telegram.ts index 886a58b..1130327 100644 --- a/lib/telegram.ts +++ b/lib/telegram.ts @@ -63,9 +63,7 @@ bot.command("end", async (ctx) => { task.noteName.replace(/\.md$/, "") }/photo-${photoIndex}.jpg`; - finalNote += `![image](data:image/jpeg;base64,${ - btoa(String.fromCharCode(...(entry.content as Uint8Array))) - })\n\n`; + finalNote += `**Photo**:\n ${photoUrl}\n\n`; photoTasks.push({ content: entry.content as Uint8Array, path: photoUrl, @@ -80,11 +78,17 @@ bot.command("end", async (ctx) => { await createDocument(task.noteName, finalNote, "text/markdown"); delete activeTasks[ctx.chat.id.toString()]; await ctx.reply("Note complete. Here is your markdown:"); - await ctx.reply(finalNote); + await ctx.reply(finalNote, { parse_mode: "MarkdownV2" }); } catch (error) { console.error("Error creating document:", error); await ctx.reply("Error creating document:"); - await ctx.reply(JSON.stringify(error)); + if (error instanceof Error) { + await ctx.reply(error?.toString()); + }else if (error instanceof Response) { + await ctx.reply(error?.statusText); + }else if (typeof error === "string") { + await ctx.reply(error); + } } });