fedimbed: cursed quote tweet resolving
This commit is contained in:
parent
c01777e2b5
commit
ecebdaa361
1 changed files with 25 additions and 0 deletions
|
@ -1421,6 +1421,17 @@ async function processUrl(msg, url, spoiler = false, command = false) {
|
||||||
content = content ?? "";
|
content = content ?? "";
|
||||||
cw = cw ?? "";
|
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);
|
content = htmlToMarkdown(content);
|
||||||
|
|
||||||
for (const emote of emotes) {
|
for (const emote of emotes) {
|
||||||
|
@ -1473,6 +1484,12 @@ async function processUrl(msg, url, spoiler = false, command = false) {
|
||||||
if (platformName == "Nitter") {
|
if (platformName == "Nitter") {
|
||||||
const newHandle = author.handle.split("@")[0];
|
const newHandle = author.handle.split("@")[0];
|
||||||
user = `${author.name} (@${newHandle})`;
|
user = `${author.name} (@${newHandle})`;
|
||||||
|
|
||||||
|
const contextHandle = context.match(/\(([^@]+?@.+?)\)/)?.[1];
|
||||||
|
if (contextHandle) {
|
||||||
|
const newContextHandle = "@" + contextHandle.split("@")[0];
|
||||||
|
context = context.replace(contextHandle, newContextHandle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseEmbed = {
|
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 {
|
return {
|
||||||
response: {
|
response: {
|
||||||
content:
|
content:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue