fedimbed: cleanup icon name replacements, twitter verified icons
This commit is contained in:
parent
ce7d5571b1
commit
ef3495bff1
2 changed files with 49 additions and 41 deletions
|
@ -319,14 +319,10 @@ function processBlueskyFacets(str, facets) {
|
|||
|
||||
function getStatsBluesky(post) {
|
||||
const stats = [];
|
||||
if (post.replyCount > 0)
|
||||
stats.push(`${Icons.fedimbed.reply.replace(":i:", ":Replies:")} ${statsFormatter.format(post.replyCount)}`);
|
||||
if (post.repostCount > 0)
|
||||
stats.push(`${Icons.fedimbed.repost.replace(":i:", ":Reposts:")} ${statsFormatter.format(post.repostCount)}`);
|
||||
if (post.quoteCount > 0)
|
||||
stats.push(`${Icons.fedimbed.quote.replace(":i:", ":Quotes:")} ${statsFormatter.format(post.quoteCount)}`);
|
||||
if (post.likeCount > 0)
|
||||
stats.push(`${Icons.fedimbed.like.replace(":i:", ":Likes:")} ${statsFormatter.format(post.likeCount)}`);
|
||||
if (post.replyCount > 0) stats.push(`${Icons.fedimbed.reply} ${statsFormatter.format(post.replyCount)}`);
|
||||
if (post.repostCount > 0) stats.push(`${Icons.fedimbed.repost} ${statsFormatter.format(post.repostCount)}`);
|
||||
if (post.quoteCount > 0) stats.push(`${Icons.fedimbed.quote} ${statsFormatter.format(post.quoteCount)}`);
|
||||
if (post.likeCount > 0) stats.push(`${Icons.fedimbed.like} ${statsFormatter.format(post.likeCount)}`);
|
||||
|
||||
return stats.join("\u3000");
|
||||
}
|
||||
|
@ -387,7 +383,7 @@ async function blueskyQuoteEmbed(quote, minimal = false) {
|
|||
? [
|
||||
{
|
||||
type: 10,
|
||||
content: `### ${Icons.fedimbed.quote.replace(":i:", ":Quoting:")} [${quote.author.displayName} (@${
|
||||
content: `### ${Icons.fedimbed.quote.replace(":Quotes:", ":Quoting:")} [${quote.author.displayName} (@${
|
||||
quote.author.handle
|
||||
})](${quoteUrl}) \u2022 <t:${Math.floor(new Date(quote.value.createdAt).getTime() / 1000)}:F>\n${content}`,
|
||||
},
|
||||
|
@ -669,11 +665,11 @@ async function bluesky(msg, url, spoiler = false, minimal = false) {
|
|||
let context = "";
|
||||
if (data.thread.parent) {
|
||||
const reply = data.thread.parent.post;
|
||||
context = `-# ${Icons.fedimbed.reply.replace(":i:", minimal ? ":ReplyingTo:" : ":i:")} ${
|
||||
minimal ? "" : "Replying to: "
|
||||
}[${reply.author.displayName} (@${reply.author.handle})](https://bsky.app/profile/${
|
||||
reply.author.did
|
||||
}/post/${reply.uri.substring(reply.uri.lastIndexOf("/") + 1)})`;
|
||||
context = `-# ${Icons.fedimbed.reply.replace(":Replies:", ":ReplyingTo:")} ${minimal ? "" : "Replying to: "}[${
|
||||
reply.author.displayName
|
||||
} (@${reply.author.handle})](https://bsky.app/profile/${reply.author.did}/post/${reply.uri.substring(
|
||||
reply.uri.lastIndexOf("/") + 1
|
||||
)})`;
|
||||
}
|
||||
|
||||
let content = post.record.text;
|
||||
|
@ -945,24 +941,20 @@ async function getStatsAS(post) {
|
|||
}
|
||||
|
||||
const stats = [];
|
||||
if (replyCount > 0)
|
||||
stats.push(`${Icons.fedimbed.reply.replace(":i:", ":Replies:")} ${statsFormatter.format(replyCount)}`);
|
||||
if (replyCount > 0) stats.push(`${Icons.fedimbed.reply} ${statsFormatter.format(replyCount)}`);
|
||||
if (post.shares?.totalItems ?? 0 > 0)
|
||||
stats.push(`${Icons.fedimbed.repost.replace(":i:", ":Reposts:")} ${statsFormatter.format(post.shares.totalItems)}`);
|
||||
stats.push(`${Icons.fedimbed.repost} ${statsFormatter.format(post.shares.totalItems)}`);
|
||||
if (post.likes?.totalItems ?? 0 > 0)
|
||||
stats.push(`${Icons.fedimbed.like.replace(":i:", ":Likes:")} ${statsFormatter.format(post.likes.totalItems)}`);
|
||||
stats.push(`${Icons.fedimbed.like} ${statsFormatter.format(post.likes.totalItems)}`);
|
||||
|
||||
return stats.join("\u3000");
|
||||
}
|
||||
|
||||
function getStatsMasto(post) {
|
||||
const stats = [];
|
||||
if (post.replies_count > 0)
|
||||
stats.push(`${Icons.fedimbed.reply.replace(":i:", ":Replies:")} ${statsFormatter.format(post.replies_count)}`);
|
||||
if (post.reblogs_count > 0)
|
||||
stats.push(`${Icons.fedimbed.repost.replace(":i:", ":Reposts:")} ${statsFormatter.format(post.reblogs_count)}`);
|
||||
if (post.favourites_count > 0)
|
||||
stats.push(`${Icons.fedimbed.like.replace(":i:", ":Likes:")} ${statsFormatter.format(post.favourites_count)}`);
|
||||
if (post.replies_count > 0) stats.push(`${Icons.fedimbed.reply} ${statsFormatter.format(post.replies_count)}`);
|
||||
if (post.reblogs_count > 0) stats.push(`${Icons.fedimbed.repost} ${statsFormatter.format(post.reblogs_count)}`);
|
||||
if (post.favourites_count > 0) stats.push(`${Icons.fedimbed.like} ${statsFormatter.format(post.favourites_count)}`);
|
||||
|
||||
return stats.join("\u3000");
|
||||
}
|
||||
|
@ -1289,6 +1281,7 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
|
|||
handle: `${authorData.preferredUsername}@${authorUrlObj.hostname}`,
|
||||
url: authorData.url,
|
||||
avatar: authorData.icon?.url,
|
||||
fields: authorData.attachment ?? authorData.fields,
|
||||
};
|
||||
} else {
|
||||
// bootleg author
|
||||
|
@ -1299,6 +1292,7 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
|
|||
name,
|
||||
handle: `${name}@${authorUrlObj.hostname}`,
|
||||
url: authorUrl,
|
||||
fields: [],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1325,6 +1319,7 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
|
|||
cw = cw ?? "";
|
||||
|
||||
let quoteRes;
|
||||
let twitterVerified = "";
|
||||
if (platformName == "Nitter") {
|
||||
const quote = content.match(/<blockquote><b>↘ <a href="([^"]+?)">/);
|
||||
if (quote?.[1]) {
|
||||
|
@ -1340,6 +1335,11 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
|
|||
content = content
|
||||
.replaceAll(/tw\.(counter-strike\.gay|c7\.pm)/g, "twitter.com")
|
||||
.replaceAll(/twitter\.com\/t\.co/g, "t.co");
|
||||
|
||||
const verifiedType = author.fields.find((f) => f.name === "Verified Type");
|
||||
if (verifiedType) {
|
||||
twitterVerified = " " + (Icons.fedimbed.verified[verifiedType.value] ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
content = content.replaceAll("`", "\u02cb").replaceAll("*", "\u2217");
|
||||
|
@ -1378,12 +1378,12 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
|
|||
if (platformName.includes("Nitter") && platformName.includes(" \u2022 ")) {
|
||||
const [_, ns] = platformName.split(" \u2022 ");
|
||||
stats = ns
|
||||
.replace("\u21a9", Icons.fedimbed.reply.replace(":i:", ":Replies:"))
|
||||
.replace("\ud83d\udd01", Icons.fedimbed.repost.replace(":i:", ":Reposts:"))
|
||||
.replace("\u2198", Icons.fedimbed.quote.replace(":i:", ":Quotes:"))
|
||||
.replace("\u2665", Icons.fedimbed.like.replace(":i:", ":Likes:"))
|
||||
.replace("\ud83d\udd16", Icons.fedimbed.bookmark.replace(":i:", ":Bookmarks:"))
|
||||
.replace("\ud83d\udc41", Icons.fedimbed.views.replace(":i:", ":Views:"))
|
||||
.replace("\u21a9", Icons.fedimbed.reply)
|
||||
.replace("\ud83d\udd01", Icons.fedimbed.repost)
|
||||
.replace("\u2198", Icons.fedimbed.quote)
|
||||
.replace("\u2665", Icons.fedimbed.like)
|
||||
.replace("\ud83d\udd16", Icons.fedimbed.bookmark)
|
||||
.replace("\ud83d\udc41", Icons.fedimbed.views)
|
||||
.replaceAll(/ <:(\w):/g, "\u3000<:$1:");
|
||||
platformName = "Twitter";
|
||||
}
|
||||
|
@ -1416,10 +1416,10 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
|
|||
};
|
||||
|
||||
let headerContent = minimal
|
||||
? `### [${author.name ? `${author.name} (${author.handle})` : author.handle}](${realUrl}) \u2022 <t:${Math.floor(
|
||||
new Date(timestamp).getTime() / 1000
|
||||
)}:F>`
|
||||
: `${author.name ? `## ${author.name}\n` : ""}-# [${author.handle}](${author.url})`;
|
||||
? `### [${
|
||||
author.name ? `${author.name} (${author.handle})` : author.handle
|
||||
}](${realUrl})${twitterVerified} \u2022 <t:${Math.floor(new Date(timestamp).getTime() / 1000)}:F>`
|
||||
: `${author.name ? `## ${author.name}${twitterVerified}\n` : ""}-# [${author.handle}](${author.url})`;
|
||||
|
||||
if (title) headerContent += minimal ? "\n**__" + title + "__**" : "\n### " + title;
|
||||
|
||||
|
@ -1567,7 +1567,10 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
|
|||
const quoteContext = `-# ${Icons.fedimbed.quote} Quoted Post`;
|
||||
if (quoteComponents[0].type == 10) {
|
||||
quoteComponents[0].content = minimal
|
||||
? quoteComponents[0].content.replace(/^### /, "$&" + Icons.fedimbed.quote.replace(":i:", ":Quoting:") + " ")
|
||||
? quoteComponents[0].content.replace(
|
||||
/^### /,
|
||||
"$&" + Icons.fedimbed.quote.replace(":Quotes:", ":Quoting:") + " "
|
||||
)
|
||||
: quoteContext + "\n" + quoteComponents[0].content;
|
||||
} else {
|
||||
quoteComponents.splice(0, 0, {type: 10, content: quoteContext});
|
||||
|
|
|
@ -581,14 +581,19 @@ module.exports.Icons = {
|
|||
blank: "<:i:1273123564173918268>",
|
||||
boat: "<:i:1273105457661087755>",
|
||||
fedimbed: {
|
||||
quote: "<:i:1308640087759654922>",
|
||||
reply: "<:i:1308640078825787412>",
|
||||
repost: "<:i:1362905247181439168>",
|
||||
like: "<:i:1362907286263300356>",
|
||||
bookmark: "<:i:1362908185781997719>",
|
||||
views: "<:i:1362909322597765270>",
|
||||
quote: "<:Quotes:1308640087759654922>",
|
||||
reply: "<:Replies:1308640078825787412>",
|
||||
repost: "<:Reposts:1362905247181439168>",
|
||||
like: "<:Likes:1362907286263300356>",
|
||||
bookmark: "<:Bookmarks:1362908185781997719>",
|
||||
views: "<:Views:1362909322597765270>",
|
||||
bluesky: "<:i:1362895346690424832>",
|
||||
twitter: "<:i:1362955359337185410>",
|
||||
verified: {
|
||||
Blue: "<:VerifiedBlue:1385752129188134962>",
|
||||
Business: "<:VerifiedBusiness:1385752141024723004>",
|
||||
Government: "<:VerifiedGovernment:1385752149706674308>",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue