diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index c33f32a..d375bf5 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -1421,6 +1421,17 @@ async function processUrl(msg, url, spoiler = false, command = false) { content = content ?? ""; cw = cw ?? ""; + let quoteRes; + if (platformName == "Nitter") { + const quote = content.match(/
↘ /); + if (quote?.[1]) { + const quoteUrl = quote[1]; + content = content.replace(/↘ .+?<\/blockquote>/, ""); + + quoteRes = await processUrl(msg, quoteUrl, spoiler, command); + } + } + content = htmlToMarkdown(content); for (const emote of emotes) { @@ -1473,6 +1484,12 @@ async function processUrl(msg, url, spoiler = false, command = false) { if (platformName == "Nitter") { const newHandle = author.handle.split("@")[0]; user = `${author.name} (@${newHandle})`; + + const contextHandle = context.match(/\(([^@]+?@.+?)\)/)?.[1]; + if (contextHandle) { + const newContextHandle = "@" + contextHandle.split("@")[0]; + context = context.replace(contextHandle, newContextHandle); + } } const baseEmbed = { @@ -1762,6 +1779,14 @@ async function processUrl(msg, url, spoiler = false, command = false) { } } + if (quoteRes) { + if (!sendWait && quoteRes.sendWait) sendWait = true; + files.push(...quoteRes.response.attachments); + const quoteEmbed = quoteRes.embeds[0]; + quoteEmbed.author = {name: "Quoted Post", icon_url: "https://cdn.discordapp.com/emojis/1308640087759654922.png"}; + embeds.push(quoteEmbed); + } + return { response: { content: