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,32 +503,36 @@ async function processUrl(msg, url) {
|
|||
}
|
||||
}
|
||||
|
||||
// NB: OceanicJS/Oceanic#32
|
||||
//await msg.edit({flags: MessageFlags.SUPPRESS_EMBEDS}).catch(() => {});
|
||||
await hf.bot.rest
|
||||
.authRequest({
|
||||
method: "PATCH",
|
||||
path: Routes.CHANNEL_MESSAGE(msg.channel.id, msg.id),
|
||||
json: {
|
||||
flags: MessageFlags.SUPPRESS_EMBEDS,
|
||||
await msg.channel
|
||||
.createMessage({
|
||||
content:
|
||||
cw && (images.length > 0 || videos.length > 0 || audios.length > 0)
|
||||
? `:warning: ${cw} || ${url} ||`
|
||||
: "",
|
||||
embeds,
|
||||
files,
|
||||
allowedMentions: {
|
||||
repliedUser: false,
|
||||
},
|
||||
messageReference: {
|
||||
messageID: msg.id,
|
||||
},
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
await msg.channel.createMessage({
|
||||
content:
|
||||
cw && (images.length > 0 || videos.length > 0 || audios.length > 0)
|
||||
? `:warning: ${cw} || ${url} ||`
|
||||
: "",
|
||||
embeds,
|
||||
files,
|
||||
allowedMentions: {
|
||||
repliedUser: false,
|
||||
},
|
||||
messageReference: {
|
||||
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(() => {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
events.add("messageCreate", "fedimbed", async function (msg) {
|
||||
|
@ -540,7 +544,7 @@ events.add("messageCreate", "fedimbed", async function (msg) {
|
|||
if (URLS_REGEX.test(msg.content)) {
|
||||
const urls = msg.content.match(URLS_REGEX);
|
||||
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)) {
|
||||
const regex = PATH_REGEX[service];
|
||||
const urlObj = new URL(url);
|
||||
|
|
Loading…
Reference in a new issue