-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
57 lines (49 loc) · 1.22 KB
/
index.ts
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
53
54
55
56
57
import {
Client,
type GroupNotification,
GroupNotificationTypes,
LocalAuth,
} from "whatsapp-web.js";
import qrcode from "qrcode-terminal";
import { handleMessage } from "./src";
const port = 3005;
const client = new Client({
authStrategy: new LocalAuth(),
webVersionCache: {
type: "remote",
remotePath:
"https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
},
puppeteer: {
executablePath:
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
// "/usr/bin/chromium",
headless: true,
args: ["--no-sandbox", "--disable-setuid-sandbox"],
},
});
client.on("qr", (qr) => {
qrcode.generate(qr, { small: true });
});
client.on("ready", () => {
console.log("Bot Siap !");
});
type Notif = {
notification: {
id: {
id: string;
};
};
};
client.on("group_update", async (notification) => {
if (notification.type === "announce") {
await client.sendMessage(notification.chatId, "Secepetan kito gas"); // Mengirim pesan
}
});
client.on("message_create", async (msg) => {
const reply = await handleMessage(msg, client);
if (reply !== undefined && reply !== null) {
await msg.reply(reply);
}
});
client.initialize();