fedimbed: strip zwsp from bridge messages, only suppress embeds if flag isnt existing and after message creation
This commit is contained in:
parent
ce2e4fd397
commit
44779f7a23
1 changed files with 29 additions and 25 deletions
|
@ -503,19 +503,8 @@ async function processUrl(msg, url) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NB: OceanicJS/Oceanic#32
|
await msg.channel
|
||||||
//await msg.edit({flags: MessageFlags.SUPPRESS_EMBEDS}).catch(() => {});
|
.createMessage({
|
||||||
await hf.bot.rest
|
|
||||||
.authRequest({
|
|
||||||
method: "PATCH",
|
|
||||||
path: Routes.CHANNEL_MESSAGE(msg.channel.id, msg.id),
|
|
||||||
json: {
|
|
||||||
flags: MessageFlags.SUPPRESS_EMBEDS,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
|
|
||||||
await msg.channel.createMessage({
|
|
||||||
content:
|
content:
|
||||||
cw && (images.length > 0 || videos.length > 0 || audios.length > 0)
|
cw && (images.length > 0 || videos.length > 0 || audios.length > 0)
|
||||||
? `:warning: ${cw} || ${url} ||`
|
? `:warning: ${cw} || ${url} ||`
|
||||||
|
@ -528,6 +517,21 @@ async function processUrl(msg, url) {
|
||||||
messageReference: {
|
messageReference: {
|
||||||
messageID: msg.id,
|
messageID: msg.id,
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
if ((msg.flags & MessageFlags.SUPPRESS_EMBEDS) === 0) {
|
||||||
|
// NB: OceanicJS/Oceanic#32
|
||||||
|
//msg.edit({flags: MessageFlags.SUPPRESS_EMBEDS}).catch(() => {});
|
||||||
|
hf.bot.rest
|
||||||
|
.authRequest({
|
||||||
|
method: "PATCH",
|
||||||
|
path: Routes.CHANNEL_MESSAGE(msg.channel.id, msg.id),
|
||||||
|
json: {
|
||||||
|
flags: MessageFlags.SUPPRESS_EMBEDS,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,7 +544,7 @@ 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) {
|
||||||
url = url.trim();
|
url = url.trim().replace("@\u200b", "@").replace("@%E2%80%8B", "@");
|
||||||
for (const service of Object.keys(PATH_REGEX)) {
|
for (const service of Object.keys(PATH_REGEX)) {
|
||||||
const regex = PATH_REGEX[service];
|
const regex = PATH_REGEX[service];
|
||||||
const urlObj = new URL(url);
|
const urlObj = new URL(url);
|
||||||
|
|
Loading…
Reference in a new issue