fedimbed: subtext to minimal with message linking

This commit is contained in:
Cynthia Foxwell 2025-05-07 20:11:16 -06:00
parent 8f5a5914ba
commit c28d79947f
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -14,7 +14,7 @@ const {htmlToMarkdown} = require("#util/html.js");
const FRIENDLY_USERAGENT = const FRIENDLY_USERAGENT =
"Mozilla/5.0 (compatible; HiddenPhox/fedimbed; +https://gitdab.com/Cynosphere/HiddenPhox) Discordbot/2.0"; "Mozilla/5.0 (compatible; HiddenPhox/fedimbed; +https://gitdab.com/Cynosphere/HiddenPhox) Discordbot/2.0";
const URLS_REGEX = /(?:\s|^|\]\()(\|\|\s*)?(https?:\/\/[^\s<]+[^<.,:;"'\]|)\s])(\s*\)?\|\||\s*[\S]*?\))?/g; const URLS_REGEX = /(?:\s|^|\]\(|-#\s+)(\|\|\s*)?(https?:\/\/[^\s<]+[^<.,:;"'\]|)\s])(\s*\)?\|\||\s*[\S]*?\))?/g;
const SPOILER_REGEX = /(?:\s|^)\|\|([\s\S]+?)\|\|/; const SPOILER_REGEX = /(?:\s|^)\|\|([\s\S]+?)\|\|/;
const BSKY_POST_REGEX = const BSKY_POST_REGEX =
@ -1601,11 +1601,13 @@ events.add("messageCreate", "fedimbed", async function (msg) {
if (URLS_REGEX.test(msg.content)) { if (URLS_REGEX.test(msg.content)) {
const urls = msg.content.match(URLS_REGEX); const urls = msg.content.match(URLS_REGEX);
for (let url of urls) { for (let url of urls) {
const minimal = /^-#\s+/.test(url);
const hasSpoiler = SPOILER_REGEX.test(url); const hasSpoiler = SPOILER_REGEX.test(url);
url = url url = url
.replace(/\|/g, "") .replace(/\|/g, "")
.replace(/^\]\(/, "") .replace(/^\]\(/, "")
.replace(/\s*[\S]*?\)$/, "") .replace(/\s*[\S]*?\)$/, "")
.replace(/^-#\s+/, "")
.trim() .trim()
.replace("#\u200b", "#") .replace("#\u200b", "#")
.replace("#%E2%80%8B", "#"); .replace("#%E2%80%8B", "#");
@ -1620,7 +1622,7 @@ events.add("messageCreate", "fedimbed", async function (msg) {
if (urlObj && regex.test(urlObj.pathname)) { if (urlObj && regex.test(urlObj.pathname)) {
if (service != "twitter") logger.verbose("fedimbed", `Hit "${service}" for "${url}", processing now.`); if (service != "twitter") logger.verbose("fedimbed", `Hit "${service}" for "${url}", processing now.`);
try { try {
const {response, sendWait} = await processUrl(msg, url, hasSpoiler); const {response, sendWait} = await processUrl(msg, url, hasSpoiler, false, false, minimal);
if (!response) return; if (!response) return;
await msg.channel.createMessage(response).then(() => { await msg.channel.createMessage(response).then(() => {
if (sendWait) { if (sendWait) {