Add reply, retweet, like counter on Discord

This commit is contained in:
dangered wolf 2022-07-16 15:19:43 -04:00
parent 80ca9ffca6
commit 42d657924c
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
3 changed files with 41 additions and 20 deletions

View file

@ -58,22 +58,22 @@ Otherwise, it will default to the first image.
In many ways, pxTwitter has richer embeds and does more. Here's a table comparing some of pxTwitter's features compared to Twitter default embeds as well as other embedding services In many ways, pxTwitter has richer embeds and does more. Here's a table comparing some of pxTwitter's features compared to Twitter default embeds as well as other embedding services
| | pxTwitter | Twitter default | vxTwitter (BetterTwitFix) | Twxtter (sixFix) | | | pxTwitter | Twitter default | vxTwitter (BetterTwitFix) | Twxtter (sixFix) |
| --------------------------------------- | :--------------------: | :------------------------------: | :-----------------------------------: | :-----------------------------------: | | --------------------------------------- | :-----------------------------: | :------------------------------: | :-----------------------------------: | :-----------------------------------: |
| Embed Tweets / Images | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | Embed Tweets / Images | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Embed profile pictures on text Tweets | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | | Embed profile pictures on text Tweets | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: |
| Embed Twitter Videos | :heavy_check_mark: | :x:¹ | :heavy_check_mark: | :heavy_check_mark: | | Embed Twitter Videos | :heavy_check_mark: | :x:¹ | :heavy_check_mark: | :heavy_check_mark: |
| Embed External Videos (YouTube, etc.) | :heavy_check_mark: | :x: | :x:⁴ | :x: | | Embed External Videos (YouTube, etc.) | :heavy_check_mark: | :x: | :x:⁴ | :x: |
| Embed Poll results | :heavy_check_mark: | :x: | :x: | :x: | | Embed Poll results | :heavy_check_mark: | :x: | :x: | :x: |
| Embed Quote Tweets | :heavy_check_mark: | :x: | :ballot_box_with_check: Without Media | :ballot_box_with_check: Without Media | | Embed Quote Tweets | :heavy_check_mark: | :x: | :ballot_box_with_check: Without Media | :ballot_box_with_check: Without Media |
| Embed Multiple Images | :x: | :heavy_minus_sign: Discord Only³ | With c.vxtwitter.com | :x: | | Embed Multiple Images | :x: | :heavy_minus_sign: Discord Only³ | With c.vxtwitter.com | :x: |
| Publicly accessible embed index | :x:² | N/A | :x:² | :heavy_check_mark: | | Publicly accessible embed index | :x:² | N/A | :x:² | :heavy_check_mark: |
| Replace t.co with original links | :heavy_check_mark: | :x: | :x: | :x: | | Replace t.co with original links | :heavy_check_mark: | :x: | :x: | :x: |
| Media-based embed colors on Discord | :heavy_check_mark: | :x: | :x: | :x: | | Media-based embed colors on Discord | :heavy_check_mark: | :x: | :x: | :x: |
| Redirect to media file (wihout embed) | :heavy_check_mark: | :x: | :x: | :heavy_check_mark: | | Redirect to media file (wihout embed) | :heavy_check_mark: | :x: | :x: | :heavy_check_mark: |
| Strip Twitter tracking info on redirect | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: | | Strip Twitter tracking info on redirect | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: |
| Show retweet / like counts | Coming soon to Discord | :x: | :heavy_check_mark: | :heavy_check_mark: | | Show retweet / like counts | :heavy_minus_sign: Discord Only | :x: | :heavy_check_mark: | :heavy_check_mark: |
| Discord / sed (`s/` replace) friendly | twittpr.com | :x: | :x: | :heavy_check_mark: | | Discord / sed (`s/` replace) friendly | twittpr.com | :x: | :x: | :heavy_check_mark: |
¹ Discord will attempt to embed Twitter's video player, but it is unreliable ¹ Discord will attempt to embed Twitter's video player, but it is unreliable

View file

@ -81,6 +81,20 @@ export const handleStatus = async (
let authorText = Strings.DEFAULT_AUTHOR_TEXT; let authorText = Strings.DEFAULT_AUTHOR_TEXT;
if (tweet.favorite_count > 0 || tweet.retweet_count > 0 || tweet.reply_count > 0) {
authorText = '';
if (tweet.reply_count > 0) {
authorText += `${tweet.reply_count} 🗩 `;
}
if (tweet.retweet_count > 0) {
authorText += `${tweet.retweet_count}`;
}
if (tweet.favorite_count > 0) {
authorText += `${tweet.favorite_count}`;
}
authorText = authorText.trim();
}
text = linkFixer(tweet, text); text = linkFixer(tweet, text);
/* Cards are used by polls and non-Twitter video embeds */ /* Cards are used by polls and non-Twitter video embeds */
@ -257,11 +271,17 @@ export const handleStatus = async (
} }
if (mediaList.length > 1) { if (mediaList.length > 1) {
authorText = `Photo ${actualMediaNumber + 1} of ${mediaList.length}`; let photoCounter = Strings.PHOTO_COUNT.format({
number: actualMediaNumber + 1,
total: mediaList.length
});
authorText =
authorText === Strings.DEFAULT_AUTHOR_TEXT
? photoCounter
: `${authorText}${photoCounter}`;
headers.push( headers.push(
`<meta property="og:site_name" content="${Constants.BRANDING_NAME} - Photo ${ `<meta property="og:site_name" content="${Constants.BRANDING_NAME} - ${photoCounter}"/>`
actualMediaNumber + 1
} of ${mediaList.length}"/>`
); );
} else { } else {
headers.push( headers.push(

View file

@ -36,6 +36,7 @@ export const Strings = {
<head>{headers}</head>`, <head>{headers}</head>`,
DEFAULT_AUTHOR_TEXT: 'Twitter', DEFAULT_AUTHOR_TEXT: 'Twitter',
QUOTE_TEXT: `═ ↘️ Quoting {name} (@{screen_name}) ═════`, QUOTE_TEXT: `═ ↘️ Quoting {name} (@{screen_name}) ═════`,
PHOTO_COUNT: `Photo {number} of {total}`,
ERROR_API_FAIL: 'Tweet failed to load due to an API error :(', ERROR_API_FAIL: 'Tweet failed to load due to an API error :(',
ERROR_PRIVATE: `I can't embed Tweets from private accounts, sorry about that :(`, ERROR_PRIVATE: `I can't embed Tweets from private accounts, sorry about that :(`,
ERROR_TWEET_NOT_FOUND: `Sorry, that Tweet doesn't exist :(` ERROR_TWEET_NOT_FOUND: `Sorry, that Tweet doesn't exist :(`