-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
52 lines (46 loc) · 1.42 KB
/
app.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const { WaBot } = require('fhy-wabot');
const QRCode = require('qrcode');
const QRCustom = async (qr) => {
try {
const url = await QRCode.toDataURL(qr);
console.log('Custom QRCode URL:', url);
} catch (err) {
console.error('Failed to generate QR URL:', err);
}
};
const AutoResponse = {
'text': {
'!text': {
response: 'pong!',
reply: false
}
// You can add other data here
},
// You can add other data types here
};
const ManualResponse = {
text: [
{
id: '[email protected]',
messageText: 'I sent text!'
}
// You can add other data here
],
// You can add other data types here
};
(async () => {
const sock = await WaBot(QRUrl = false, QRCustom, AutoResponse, ManualResponse, self = false);
sock.ev.on('messages.upsert', async (messageUpdate) => {
const message = messageUpdate.messages[0];
const sender = message.key.remoteJid;
const text = message.message.conversation || message.message.extendedTextMessage?.text || '';
if (text.toLowerCase() === '.test') {
try {
await sock.sendMessage(sender, { text: 'oh hello there' });
} catch (error) {
console.error(`Error occurred: ${error.message}`);
}
}
// You can add other advanced data here
});
})();