mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-21 13:19:21 +00:00
fix: check message types on wbotMessageListener
This commit is contained in:
@@ -146,6 +146,21 @@ const handleMessage = async (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isValidMsg = (msg: WbotMessage): boolean => {
|
||||||
|
if (msg.from === "status@broadcast" || msg.author) return false;
|
||||||
|
if (
|
||||||
|
msg.type === "chat" ||
|
||||||
|
msg.type === "audio" ||
|
||||||
|
msg.type === "ptt" ||
|
||||||
|
msg.type === "video" ||
|
||||||
|
msg.type === "image" ||
|
||||||
|
msg.type === "document" ||
|
||||||
|
msg.type === "vcard"
|
||||||
|
)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const wbotMessageListener = (whatsapp: Whatsapp): void => {
|
const wbotMessageListener = (whatsapp: Whatsapp): void => {
|
||||||
const whatsappId = whatsapp.id;
|
const whatsappId = whatsapp.id;
|
||||||
const wbot = getWbot(whatsappId);
|
const wbot = getWbot(whatsappId);
|
||||||
@@ -159,12 +174,7 @@ const wbotMessageListener = (whatsapp: Whatsapp): void => {
|
|||||||
wbot.on("message_create", async msg => {
|
wbot.on("message_create", async msg => {
|
||||||
console.log(msg.type);
|
console.log(msg.type);
|
||||||
|
|
||||||
if (
|
if (!isValidMsg(msg)) {
|
||||||
msg.from === "status@broadcast" ||
|
|
||||||
msg.type === "location" ||
|
|
||||||
msg.type === "call_log" ||
|
|
||||||
msg.author // Ignore Group Messages
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user