mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-04 10:00:55 +01:00
Better t.co replacement
This commit is contained in:
parent
574731af0a
commit
4f1d659a3d
1 changed files with 6 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
import { Constants } from "./constants";
|
||||
import { fetchUsingGuest } from "./drivers/guest";
|
||||
import { fetchUsingGuest } from "./fetch";
|
||||
import { Html } from "./html";
|
||||
import { renderPoll } from "./poll";
|
||||
import { rgbToHex } from "./utils";
|
||||
|
@ -60,7 +60,7 @@ export const handleStatus = async (handle: string, id: string, mediaNumber?: num
|
|||
if (tweet.display_text_range) {
|
||||
const [start, end] = tweet.display_text_range;
|
||||
// We ignore start because it cuts off reply handles
|
||||
text = text.substring(0, end + 1);
|
||||
// text = text.substring(0, end + 1);
|
||||
}
|
||||
|
||||
if (tweet.card) {
|
||||
|
@ -72,6 +72,7 @@ export const handleStatus = async (handle: string, id: string, mediaNumber?: num
|
|||
tweet.entities?.urls.forEach((url: TcoExpansion) => {
|
||||
text = text.replace(url.url, url.expanded_url);
|
||||
});
|
||||
text = text.replace(/ ?https\:\/\/t\.co\/\w{10}/, '');
|
||||
}
|
||||
|
||||
if (typeof tweet.extended_entities?.media === 'undefined' && typeof tweet.entities?.media === 'undefined') {
|
||||
|
@ -159,11 +160,11 @@ export const handleStatus = async (handle: string, id: string, mediaNumber?: num
|
|||
);
|
||||
}
|
||||
|
||||
if (typeof tweet.in_reply_to_screen_name !== "undefined") {
|
||||
authorText = `↪️ @${tweet.in_reply_to_screen_name}`;
|
||||
if (tweet.in_reply_to_screen_name) {
|
||||
authorText = `↪ Replying to @${tweet.in_reply_to_screen_name}`;
|
||||
}
|
||||
|
||||
headers.push(`<link rel="alternate" href="https://pxtwitter.com/owoembed?text=${authorText}" type="application/json+oembed" title="${name}">`)
|
||||
headers.push(`<link rel="alternate" href="https://pxtwitter.com/owoembed?text=${encodeURIComponent(authorText)}&status=${encodeURIComponent(id)}&author=${encodeURIComponent(user?.screen_name || '')}" type="application/json+oembed" title="${name}">`)
|
||||
|
||||
console.log(JSON.stringify(tweet))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue