-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (29 loc) · 964 Bytes
/
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
// Supports ES6
// import { create, Whatsapp } from 'venom-bot';
const { create, Client } = require("venom-bot");
const msgHandler = require("./msgHndlr");
const options = require('./options')
const start = async (client = new Client()) => {
console.log("[SERVER] Server Started!");
// Force it to keep the current session
client.onStateChange((state) => {
console.log("[Client State]", state);
if (state === "CONFLICT" || state === "UNLAUNCHED") client.forceRefocus();
});
// listening on message
client.onMessage(async (message) => {
msgHandler(client, message);
});
client.onIncomingCall(async (call) => {
console.log(call)
await client
.sendText(
call.peerJid,
"Maaf, saya tidak bisa menerima panggilan. nelfon = block!"
)
.then(() => client.blockContact(call.peerJid));
});
};
create(options(true, start))
.then((client) => start(client))
.catch((error) => console.log(error));