forked from PluralFlux/PluralFlux
changed parseProxyTags to filter proxy differently. changed conditional in sendMessageAsMember because obj will never not exist
This commit is contained in:
@@ -52,18 +52,20 @@ msgh.parseProxyTags = async function (authorId, content, attachmentUrl= null){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const proxyMessage = {}
|
const proxyMessage = {}
|
||||||
members.filter(member => member.proxy).forEach(member => {
|
members.forEach(member => {
|
||||||
const splitProxy = member.proxy.split("text");
|
if (member.proxy) {
|
||||||
if(content.startsWith(splitProxy[0]) && content.endsWith(splitProxy[1])) {
|
const splitProxy = member.proxy.split("text");
|
||||||
proxyMessage.member = member;
|
if(content.startsWith(splitProxy[0]) && content.endsWith(splitProxy[1])) {
|
||||||
if (attachmentUrl) return proxyMessage.message = enums.misc.ATTACHMENT_SENT_BY;
|
proxyMessage.member = member;
|
||||||
|
if (attachmentUrl) return proxyMessage.message = enums.misc.ATTACHMENT_SENT_BY;
|
||||||
|
|
||||||
let escapedPrefix = splitProxy[0].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
let escapedPrefix = splitProxy[0].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
let escapedSuffix = splitProxy[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
let escapedSuffix = splitProxy[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
escapedPrefix = new RegExp("^" + escapedPrefix);
|
escapedPrefix = new RegExp("^" + escapedPrefix);
|
||||||
escapedSuffix = new RegExp(escapedSuffix + "$")
|
escapedSuffix = new RegExp(escapedSuffix + "$")
|
||||||
proxyMessage.message = content.replace(escapedPrefix, "").replace(escapedSuffix, "");
|
proxyMessage.message = content.replace(escapedPrefix, "").replace(escapedSuffix, "");
|
||||||
if (proxyMessage.message.length === 0) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
|
if (proxyMessage.message.length === 0) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return proxyMessage;
|
return proxyMessage;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ wh.sendMessageAsMember = async function(client, message) {
|
|||||||
const attachmentUrl = message.attachments.size > 0 ? message.attachments.first().url : null;
|
const attachmentUrl = message.attachments.size > 0 ? message.attachments.first().url : null;
|
||||||
const proxyMatch = await messageHelper.parseProxyTags(message.author.id, message.content, attachmentUrl).catch(e =>{throw e});
|
const proxyMatch = await messageHelper.parseProxyTags(message.author.id, message.content, attachmentUrl).catch(e =>{throw e});
|
||||||
// If the message doesn't match a proxy, just return.
|
// If the message doesn't match a proxy, just return.
|
||||||
if (!proxyMatch || !proxyMatch.member.proxy) {
|
if (!proxyMatch.member) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If the message does match a proxy but is not in a guild server (ex: in the Bot's DMs
|
// If the message does match a proxy but is not in a guild server (ex: in the Bot's DMs
|
||||||
|
|||||||
Reference in New Issue
Block a user