Deploy: 2026-05-23 22:37:14
This commit is contained in:
@@ -437,6 +437,24 @@ async function sendMessage(session_key, phone, message, mediaUrl = null, audioBa
|
||||
return sentMsg;
|
||||
}
|
||||
|
||||
async function checkContact(session_key, phone) {
|
||||
const sock = sessions.get(session_key);
|
||||
if (!sock) {
|
||||
throw new Error(`Session ${session_key} is not active or connected`);
|
||||
}
|
||||
const jid = phone.includes('@') ? phone : `${phone}@s.whatsapp.net`;
|
||||
try {
|
||||
const result = await sock.onWhatsApp(jid);
|
||||
if (result && result.length > 0) {
|
||||
return result[0];
|
||||
}
|
||||
return { exists: false, jid };
|
||||
} catch (err) {
|
||||
console.error(`[Baileys] Error checking contact ${jid}:`, err.message);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
function getActiveSessions() {
|
||||
return Array.from(sessions.keys());
|
||||
}
|
||||
@@ -445,6 +463,7 @@ module.exports = {
|
||||
startSession,
|
||||
disconnectSession,
|
||||
sendMessage,
|
||||
getActiveSessions
|
||||
getActiveSessions,
|
||||
checkContact
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user