mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-17 01:55:27 +10:00
adjusting logic for parsing proxy tags
This commit is contained in:
@@ -44,10 +44,16 @@ msgh.parseProxyTags = async function (authorId, attachment, content){
|
|||||||
const proxyMessage = {}
|
const proxyMessage = {}
|
||||||
members.filter(member => member.proxy).forEach(member => {
|
members.filter(member => member.proxy).forEach(member => {
|
||||||
const splitProxy = member.proxy.split("text");
|
const splitProxy = member.proxy.split("text");
|
||||||
|
console.log(splitProxy);
|
||||||
if(content.startsWith(splitProxy[0]) && content.endsWith(splitProxy[1])) {
|
if(content.startsWith(splitProxy[0]) && content.endsWith(splitProxy[1])) {
|
||||||
if (content.length <= member.proxy.length && !attachment) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
|
console.log(content);
|
||||||
proxyMessage.proxy = member.proxy;
|
proxyMessage.proxy = member.proxy;
|
||||||
proxyMessage.message = content.slice(member.proxy.length).trim();
|
const removePrefix = new RegExp("^" + splitProxy[0]);
|
||||||
|
const removeSuffix = new RegExp(splitProxy[1] + "$");
|
||||||
|
proxyMessage.message = content.replace(removePrefix, "").replace(removeSuffix, "");
|
||||||
|
console.log(proxyMessage);
|
||||||
|
if (proxyMessage.message.length <= splitProxy[0].length + splitProxy[1].length && !attachment) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return proxyMessage;
|
return proxyMessage;
|
||||||
|
|||||||
Reference in New Issue
Block a user