fedimbed: sacrifice char count for emote names

This commit is contained in:
Cynthia Foxwell 2025-05-30 14:57:16 -06:00
parent fae3086da2
commit ce7d5571b1
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -319,10 +319,14 @@ function processBlueskyFacets(str, facets) {
function getStatsBluesky(post) { function getStatsBluesky(post) {
const stats = []; const stats = [];
if (post.replyCount > 0) stats.push(`${Icons.fedimbed.reply} ${statsFormatter.format(post.replyCount)}`); if (post.replyCount > 0)
if (post.repostCount > 0) stats.push(`${Icons.fedimbed.repost} ${statsFormatter.format(post.repostCount)}`); stats.push(`${Icons.fedimbed.reply.replace(":i:", ":Replies:")} ${statsFormatter.format(post.replyCount)}`);
if (post.quoteCount > 0) stats.push(`${Icons.fedimbed.quote} ${statsFormatter.format(post.quoteCount)}`); if (post.repostCount > 0)
if (post.likeCount > 0) stats.push(`${Icons.fedimbed.like} ${statsFormatter.format(post.likeCount)}`); 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)}`);
return stats.join("\u3000"); return stats.join("\u3000");
} }
@ -383,7 +387,7 @@ async function blueskyQuoteEmbed(quote, minimal = false) {
? [ ? [
{ {
type: 10, type: 10,
content: `### ${Icons.fedimbed.quote} [${quote.author.displayName} (@${ content: `### ${Icons.fedimbed.quote.replace(":i:", ":Quoting:")} [${quote.author.displayName} (@${
quote.author.handle quote.author.handle
})](${quoteUrl}) \u2022 <t:${Math.floor(new Date(quote.value.createdAt).getTime() / 1000)}:F>\n${content}`, })](${quoteUrl}) \u2022 <t:${Math.floor(new Date(quote.value.createdAt).getTime() / 1000)}:F>\n${content}`,
}, },
@ -665,9 +669,11 @@ async function bluesky(msg, url, spoiler = false, minimal = false) {
let context = ""; let context = "";
if (data.thread.parent) { if (data.thread.parent) {
const reply = data.thread.parent.post; const reply = data.thread.parent.post;
context = `-# ${Icons.fedimbed.reply} ${minimal ? "" : "Replying to: "}[${reply.author.displayName} (@${ context = `-# ${Icons.fedimbed.reply.replace(":i:", minimal ? ":ReplyingTo:" : ":i:")} ${
reply.author.handle minimal ? "" : "Replying to: "
})](https://bsky.app/profile/${reply.author.did}/post/${reply.uri.substring(reply.uri.lastIndexOf("/") + 1)})`; }[${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; let content = post.record.text;
@ -939,20 +945,24 @@ async function getStatsAS(post) {
} }
const stats = []; const stats = [];
if (replyCount > 0) stats.push(`${Icons.fedimbed.reply} ${statsFormatter.format(replyCount)}`); if (replyCount > 0)
stats.push(`${Icons.fedimbed.reply.replace(":i:", ":Replies:")} ${statsFormatter.format(replyCount)}`);
if (post.shares?.totalItems ?? 0 > 0) if (post.shares?.totalItems ?? 0 > 0)
stats.push(`${Icons.fedimbed.repost} ${statsFormatter.format(post.shares.totalItems)}`); stats.push(`${Icons.fedimbed.repost.replace(":i:", ":Reposts:")} ${statsFormatter.format(post.shares.totalItems)}`);
if (post.likes?.totalItems ?? 0 > 0) if (post.likes?.totalItems ?? 0 > 0)
stats.push(`${Icons.fedimbed.like} ${statsFormatter.format(post.likes.totalItems)}`); stats.push(`${Icons.fedimbed.like.replace(":i:", ":Likes:")} ${statsFormatter.format(post.likes.totalItems)}`);
return stats.join("\u3000"); return stats.join("\u3000");
} }
function getStatsMasto(post) { function getStatsMasto(post) {
const stats = []; const stats = [];
if (post.replies_count > 0) stats.push(`${Icons.fedimbed.reply} ${statsFormatter.format(post.replies_count)}`); if (post.replies_count > 0)
if (post.reblogs_count > 0) stats.push(`${Icons.fedimbed.repost} ${statsFormatter.format(post.reblogs_count)}`); stats.push(`${Icons.fedimbed.reply.replace(":i:", ":Replies:")} ${statsFormatter.format(post.replies_count)}`);
if (post.favourites_count > 0) stats.push(`${Icons.fedimbed.like} ${statsFormatter.format(post.favourites_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)}`);
return stats.join("\u3000"); return stats.join("\u3000");
} }
@ -1368,13 +1378,13 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
if (platformName.includes("Nitter") && platformName.includes(" \u2022 ")) { if (platformName.includes("Nitter") && platformName.includes(" \u2022 ")) {
const [_, ns] = platformName.split(" \u2022 "); const [_, ns] = platformName.split(" \u2022 ");
stats = ns stats = ns
.replace("\u21a9", Icons.fedimbed.reply) .replace("\u21a9", Icons.fedimbed.reply.replace(":i:", ":Replies:"))
.replace("\ud83d\udd01", Icons.fedimbed.repost) .replace("\ud83d\udd01", Icons.fedimbed.repost.replace(":i:", ":Reposts:"))
.replace("\u2198", Icons.fedimbed.quote) .replace("\u2198", Icons.fedimbed.quote.replace(":i:", ":Quotes:"))
.replace("\u2665", Icons.fedimbed.like) .replace("\u2665", Icons.fedimbed.like.replace(":i:", ":Likes:"))
.replace("\ud83d\udd16", Icons.fedimbed.bookmark) .replace("\ud83d\udd16", Icons.fedimbed.bookmark.replace(":i:", ":Bookmarks:"))
.replace("\ud83d\udc41", Icons.fedimbed.views) .replace("\ud83d\udc41", Icons.fedimbed.views.replace(":i:", ":Views:"))
.replaceAll(/ <:i:/g, "\u3000<:i:"); .replaceAll(/ <:(\w):/g, "\u3000<:$1:");
platformName = "Twitter"; platformName = "Twitter";
} }
@ -1557,7 +1567,7 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
const quoteContext = `-# ${Icons.fedimbed.quote} Quoted Post`; const quoteContext = `-# ${Icons.fedimbed.quote} Quoted Post`;
if (quoteComponents[0].type == 10) { if (quoteComponents[0].type == 10) {
quoteComponents[0].content = minimal quoteComponents[0].content = minimal
? quoteComponents[0].content.replace(/^### /, "$&" + Icons.fedimbed.quote + " ") ? quoteComponents[0].content.replace(/^### /, "$&" + Icons.fedimbed.quote.replace(":i:", ":Quoting:") + " ")
: quoteContext + "\n" + quoteComponents[0].content; : quoteContext + "\n" + quoteComponents[0].content;
} else { } else {
quoteComponents.splice(0, 0, {type: 10, content: quoteContext}); quoteComponents.splice(0, 0, {type: 10, content: quoteContext});