fedimbed: sacrifice char count for emote names
This commit is contained in:
parent
fae3086da2
commit
ce7d5571b1
1 changed files with 32 additions and 22 deletions
|
@ -319,10 +319,14 @@ function processBlueskyFacets(str, facets) {
|
|||
|
||||
function getStatsBluesky(post) {
|
||||
const stats = [];
|
||||
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)}`);
|
||||
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)}`);
|
||||
|
||||
return stats.join("\u3000");
|
||||
}
|
||||
|
@ -383,7 +387,7 @@ async function blueskyQuoteEmbed(quote, minimal = false) {
|
|||
? [
|
||||
{
|
||||
type: 10,
|
||||
content: `### ${Icons.fedimbed.quote} [${quote.author.displayName} (@${
|
||||
content: `### ${Icons.fedimbed.quote.replace(":i:", ":Quoting:")} [${quote.author.displayName} (@${
|
||||
quote.author.handle
|
||||
})](${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 = "";
|
||||
if (data.thread.parent) {
|
||||
const reply = data.thread.parent.post;
|
||||
context = `-# ${Icons.fedimbed.reply} ${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(":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)})`;
|
||||
}
|
||||
|
||||
let content = post.record.text;
|
||||
|
@ -939,20 +945,24 @@ async function getStatsAS(post) {
|
|||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
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");
|
||||
}
|
||||
|
||||
function getStatsMasto(post) {
|
||||
const stats = [];
|
||||
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)}`);
|
||||
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)}`);
|
||||
|
||||
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 ")) {
|
||||
const [_, ns] = platformName.split(" \u2022 ");
|
||||
stats = ns
|
||||
.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(/ <:i:/g, "\u3000<:i:");
|
||||
.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:"))
|
||||
.replaceAll(/ <:(\w):/g, "\u3000<:$1:");
|
||||
platformName = "Twitter";
|
||||
}
|
||||
|
||||
|
@ -1557,7 +1567,7 @@ 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 + " ")
|
||||
? quoteComponents[0].content.replace(/^### /, "$&" + Icons.fedimbed.quote.replace(":i:", ":Quoting:") + " ")
|
||||
: quoteContext + "\n" + quoteComponents[0].content;
|
||||
} else {
|
||||
quoteComponents.splice(0, 0, {type: 10, content: quoteContext});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue