fedi moji :3

This commit is contained in:
Ashley 2024-08-22 15:34:03 +00:00
parent a9b3d84366
commit 09846c524c
9 changed files with 100 additions and 31 deletions

View file

@ -88,6 +88,21 @@ export default function(client) {
client.error = client.log;
client.uploadMedia = async function(url) {
var matrixUrl = client.cache.get(url);
if(!matrixUrl) {
const buffer = await fetch(url, {
headers: {
"User-Agent": "PossumBot/1.0 (+https://bot.possum.city/)",
},
}).then((res) => res.arrayBuffer()).then((buf) => Buffer.from(buf));
const uploadResponse = await client.uploadContent(buffer, { rawResponse: false });
matrixUrl = uploadResponse.content_uri;
client.cache.set(url, matrixUrl);
}
return matrixUrl;
}
if(fs.existsSync("data/cache.json")) {
var data = fs.readFileSync("data/cache.json");

View file

@ -71,7 +71,7 @@ async function resolvePlatform(url) {
return nodeinfo.software.name;
}
const keyId = "https://bot.possum.city/actor#main-key";
const keyId = "https://" + process.env.AP_FETCH_DOMAIN + "/actor#main-key";
const privKey = fs.readFileSync("data/private.pem");
async function signedFetch(url, options) {
const urlObj = new URL(url);
@ -498,10 +498,9 @@ async function processUrl(url) {
cw = cw ?? "";
//content = htmlToMarkdown(content);
for(const emote of emotes) {
//content = content.replaceAll(emote.name, `[${emote.name}](${emote.url})`);
content = content.replaceAll(emote.name, `<img src="${emote.url}" alt="${emote.name}" />`);
}
//for(const emote of emotes) {
// content = content.replaceAll(emote.name, `<img src="${emote.url}" alt="${emote.name}" />`);
//}
//cw = htmlToMarkdown(cw);
@ -562,7 +561,8 @@ async function processUrl(url) {
? `<span data-mx-spoiler>${url}</span>`
: "",
embeds,
files
files,
emotes
};
}