mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-08-25 19:07:17 +01:00
Tweets only translated if asked
This commit is contained in:
parent
1a384aded9
commit
12c6737877
3 changed files with 10 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
BRANDING_NAME = "pxTwitter"
|
BRANDING_NAME = "pxTwitter"
|
||||||
BRANDING_NAME_DISCORD = "pxTwitter // Twittpr - Embed videos, polls & more!"
|
BRANDING_NAME_DISCORD = "pxTwitter // Twittpr - Embed videos, polls & more!"
|
||||||
DIRECT_MEDIA_DOMAINS = "d.pxtwitter.com,d.twittpr.com,dl.pxtwitter.com,dl.twittpr.com"
|
DIRECT_MEDIA_DOMAINS = "d.pxtwitter.com,d.twittpr.com,dl.pxtwitter.com,dl.twittpr.com"
|
||||||
MOSAIC_DOMAIN_LIST = "mosaic1.pxtwitter.com,mosaic2.pxtwitter.com"
|
MOSAIC_DOMAIN_LIST = "mosaic.pxtwitter.com"
|
||||||
HOST_URL = "https://pxtwitter.com"
|
HOST_URL = "https://pxtwitter.com"
|
||||||
REDIRECT_URL = "https://github.com/dangeredwolf/pxTwitter"
|
REDIRECT_URL = "https://github.com/dangeredwolf/pxTwitter"
|
|
@ -77,14 +77,13 @@ export const handleStatus = async (
|
||||||
|
|
||||||
let text = tweet.full_text;
|
let text = tweet.full_text;
|
||||||
let engagementText = '';
|
let engagementText = '';
|
||||||
|
|
||||||
const user = tweet.user;
|
const user = tweet.user;
|
||||||
const screenName = user?.screen_name || '';
|
const screenName = user?.screen_name || '';
|
||||||
const name = user?.name || '';
|
const name = user?.name || '';
|
||||||
|
|
||||||
if (
|
/* If a language is specified, let's try translating it! */
|
||||||
(typeof language === 'string' && language.length === 2) ||
|
if (typeof language === 'string' && language.length === 2) {
|
||||||
(tweet.lang !== 'en' && tweet.lang !== 'unk')
|
|
||||||
) {
|
|
||||||
text = await translateTweet(tweet, conversation.guestToken || '', language || 'en');
|
text = await translateTweet(tweet, conversation.guestToken || '', language || 'en');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +93,7 @@ export const handleStatus = async (
|
||||||
|
|
||||||
let authorText = Strings.DEFAULT_AUTHOR_TEXT;
|
let authorText = Strings.DEFAULT_AUTHOR_TEXT;
|
||||||
|
|
||||||
|
/* Build out reply, retweet, like counts */
|
||||||
if (tweet.favorite_count > 0 || tweet.retweet_count > 0 || tweet.reply_count > 0) {
|
if (tweet.favorite_count > 0 || tweet.retweet_count > 0 || tweet.reply_count > 0) {
|
||||||
authorText = '';
|
authorText = '';
|
||||||
if (tweet.reply_count > 0) {
|
if (tweet.reply_count > 0) {
|
||||||
|
@ -107,7 +107,7 @@ export const handleStatus = async (
|
||||||
}
|
}
|
||||||
authorText = authorText.trim();
|
authorText = authorText.trim();
|
||||||
|
|
||||||
// engagementText has less spacing than authorText, also Telegram interprets the other heart as emoji
|
// engagementText has less spacing than authorText
|
||||||
engagementText = authorText.replace(/ /g, ' ');
|
engagementText = authorText.replace(/ /g, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,9 +134,9 @@ export const handleStatus = async (
|
||||||
conversation?.globalObjects?.users?.[quoteTweetMaybe.user_id_str] || {};
|
conversation?.globalObjects?.users?.[quoteTweetMaybe.user_id_str] || {};
|
||||||
const quoteText = handleQuote(quoteTweetMaybe);
|
const quoteText = handleQuote(quoteTweetMaybe);
|
||||||
|
|
||||||
console.log('quoteText', quoteText);
|
|
||||||
|
|
||||||
if (quoteText) {
|
if (quoteText) {
|
||||||
|
console.log('quoteText', quoteText);
|
||||||
|
|
||||||
text += `\n${quoteText}`;
|
text += `\n${quoteText}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,6 @@ export const handleStatus = async (
|
||||||
let palette = user?.profile_image_extensions_media_color?.palette;
|
let palette = user?.profile_image_extensions_media_color?.palette;
|
||||||
let colorOverride: string = Constants.DEFAULT_COLOR;
|
let colorOverride: string = Constants.DEFAULT_COLOR;
|
||||||
|
|
||||||
// for loop for palettes
|
|
||||||
if (palette) {
|
if (palette) {
|
||||||
colorOverride = colorFromPalette(palette);
|
colorOverride = colorFromPalette(palette);
|
||||||
}
|
}
|
||||||
|
@ -241,6 +240,7 @@ export const handleStatus = async (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is for the video thumbnail */
|
||||||
headers.push(`<meta name="twitter:image" content="${media.media_url_https}"/>`);
|
headers.push(`<meta name="twitter:image" content="${media.media_url_https}"/>`);
|
||||||
|
|
||||||
/* On Discord we have to use the author field in order to get the tweet text
|
/* On Discord we have to use the author field in order to get the tweet text
|
||||||
|
|
|
@ -38,7 +38,7 @@ export const Strings = {
|
||||||
|
|
||||||
QUOTE_TEXT: `═ ↘️ Quoting {name} (@{screen_name}) ═════`,
|
QUOTE_TEXT: `═ ↘️ Quoting {name} (@{screen_name}) ═════`,
|
||||||
TRANSLATE_TEXT: `═ ↘️ Translated from {language} ═════`,
|
TRANSLATE_TEXT: `═ ↘️ Translated from {language} ═════`,
|
||||||
TRANSLATE_TEXT_INTL: `═ ↘️ {source} -> {destination} ═════`,
|
TRANSLATE_TEXT_INTL: `═ ↘️ {source} ➡️ {destination} ═════`,
|
||||||
PHOTO_COUNT: `Photo {number} of {total}`,
|
PHOTO_COUNT: `Photo {number} of {total}`,
|
||||||
|
|
||||||
SINGULAR_DAY_LEFT: 'day left',
|
SINGULAR_DAY_LEFT: 'day left',
|
||||||
|
|
Loading…
Add table
Reference in a new issue