-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.js
26 lines (23 loc) · 915 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const wa = require('velixs-md')
wa.setCredentialsDir('./storage/wa_credentials');
wa.startSession('ilsya');
wa.onConnected(async (sessionId) => {
console.log('Session Connected : '+ sessionId);
})
wa.onMessageReceived(async(msg)=>{
if (msg.key.fromMe || msg.key.remoteJid.includes("status")) return;
if(msg.message?.extendedTextMessage?.text == 'ping'){ // jika pesan berupa text dan berisi ping
// maka kirim pesan pong
await wa.sendTextMessage({
sessionId: msg.sessionId, // ini session ilsya
to: msg.key.remoteJid, // ini pengirim pesan ping
text: "pong",
answering: msg, // ini untuk reply pesan
isGroup : wa.isGroup(msg.key.remoteJid) // buat ngecek pengirimnya dari group atau personal
}).then(res => {
console.log(res);
}).catch(err => {
console.log(err);
})
}
})