fedimbed: cursed quote tweet resolving

This commit is contained in:
Cynthia Foxwell 2025-04-17 23:28:51 -06:00
parent c01777e2b5
commit ecebdaa361
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -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(/<blockquote><b>↘ <a href="([^"]+?)">/);
if (quote?.[1]) {
const quoteUrl = quote[1];
content = content.replace(/<blockquote><b>↘ <a href="[^"]+?">.+?<\/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: