-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
52 lines (43 loc) · 1.65 KB
/
index.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 { create, decryptMedia } = require('@open-wa/wa-automate');
const configObject = {
sessionId: 'SAD_CLIENT',
authTimeout: 60,
autoRefresh: true,
cacheEnabled: false,
chromiumArgs: ['--no-sandbox'],
disableSpins: true,
headless: true,
qrRefreshS: 20,
qrTimeout: 0,
};
const ops = process.platform;
if (ops === 'win32' || ops === 'win64') configObject['executeablePath'] = 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe';
else if (ops === 'linux') configObject['executeablePath'] = '/usr/bin/google-chrome-stable';
else if (ops === 'darwin') configObject['executeablePath'] = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
const startBot = async () => {
try {
const Handler = require('./handler');
const Client = await create(configObject);
await Client.onStateChanged(async (state) => {
if (state === 'TIMEOUT' || state === 'CONFLICT' || state === 'UNLAUNCHED') await Client.forceRefocus();
console.log('State Changed >', state);
});
await Client.onMessage((message) => {
Handler.messageHandler(Client, message);
});
await Client.onGlobalParticipantsChanged((event) => {
Handler.globalParticipantsChanged(Client, event);
});
await Client.onAddedToGroup((event) => {
Handler.addedToGroup(Client, event);
});
await Client.onIncomingCall(async (call) => {
const { peerJid } = call;
await Client.contactBlock(peerJid);
await Client.sendText(peerJid, '_⚠️ Bot is busy, do not call! DM *@niduka_akalanka_* on Instagram to Unblock!_');
});
} catch (error) {
console.log('Error When start bot ' + error);
}
};
startBot();