fedimbed: spoiler cw'd media
This commit is contained in:
parent
a3f782e941
commit
e1af92f9d1
1 changed files with 14 additions and 6 deletions
|
@ -8,7 +8,8 @@ const {parseHtmlEntities, getUploadLimit} = require("../lib/utils.js");
|
|||
const FRIENDLY_USERAGENT =
|
||||
"HiddenPhox/fedimbed (https://gitdab.com/Cynosphere/HiddenPhox)";
|
||||
|
||||
const URLS_REGEX = /(?:\s|^)(\|\|\s*)?(https?:\/\/[^\s<]+[^<.,:;"'\]\s])(\s+\|\|)?/g;
|
||||
const URLS_REGEX =
|
||||
/(?:\s|^)(\|\|\s*)?(https?:\/\/[^\s<]+[^<.,:;"'\]\s])(\s+\|\|)?/g;
|
||||
const SPOILER_REGEX = /^\|\|([\s\S]+?)\|\|/;
|
||||
|
||||
const PATH_REGEX = {
|
||||
|
@ -468,7 +469,7 @@ async function processUrl(msg, url, spoiler = false) {
|
|||
|
||||
files.push({
|
||||
name:
|
||||
attachment.type.indexOf("/") > -1
|
||||
(cw != "" || spoiler ? "SPOILER_" : "") + attachment.type.indexOf("/") > -1
|
||||
? attachment.type.replace("/", ".")
|
||||
: attachment.type +
|
||||
"." +
|
||||
|
@ -500,7 +501,7 @@ async function processUrl(msg, url, spoiler = false) {
|
|||
|
||||
files.push({
|
||||
name:
|
||||
attachment.type.indexOf("/") > -1
|
||||
(cw != "" || spoiler ? "SPOILER_" : "") + attachment.type.indexOf("/") > -1
|
||||
? attachment.type
|
||||
.replace("/", ".")
|
||||
.replace("mpeg", "mp3")
|
||||
|
@ -524,9 +525,12 @@ async function processUrl(msg, url, spoiler = false) {
|
|||
await msg.channel
|
||||
.createMessage({
|
||||
content:
|
||||
cw && (images.length > 0 || videos.length > 0 || audios.length > 0)
|
||||
cw != "" &&
|
||||
(images.length > 0 || videos.length > 0 || audios.length > 0)
|
||||
? `:warning: ${cw} || ${url} ||`
|
||||
: spoiler ? `|| ${url} ||` : "",
|
||||
: spoiler
|
||||
? `|| ${url} ||`
|
||||
: "",
|
||||
embeds,
|
||||
files,
|
||||
allowedMentions: {
|
||||
|
@ -567,7 +571,11 @@ events.add("messageCreate", "fedimbed", async function (msg) {
|
|||
const urls = msg.content.match(URLS_REGEX);
|
||||
for (let url of urls) {
|
||||
const hasSpoiler = SPOILER_REGEX.test(url);
|
||||
url = url.replace(/\|/g,"").trim().replace("@\u200b", "@").replace("@%E2%80%8B", "@");
|
||||
url = url
|
||||
.replace(/\|/g, "")
|
||||
.trim()
|
||||
.replace("@\u200b", "@")
|
||||
.replace("@%E2%80%8B", "@");
|
||||
for (const service of Object.keys(PATH_REGEX)) {
|
||||
const regex = PATH_REGEX[service];
|
||||
const urlObj = new URL(url);
|
||||
|
|
Loading…
Reference in a new issue