-
Notifications
You must be signed in to change notification settings - Fork 12
/
index2.js
38 lines (36 loc) · 1.25 KB
/
index2.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
const makeWASocket = require("@adiwajshing/baileys").default
const qrcode = require("qrcode-terminal")
const fs = require('fs')
const pino = require('pino')
const { delay , useMultiFileAuthState,BufferJSON, fetchLatestBaileysVersion } = require("@adiwajshing/baileys")
async function qr() {
//------------------------------------------------------
let { version, isLatest } = await fetchLatestBaileysVersion()
const { state, saveCreds } =await useMultiFileAuthState(`./session`)
const session = makeWASocket({
logger: pino({ level: 'silent' }),
printQRInTerminal: true,
browser: ['Alien-Alfa','opera','1.0.0'],
auth: state,
version
})
//------------------------------------------------------
session.ev.on("connection.update",async (s) => {
const { connection, lastDisconnect } = s
if (connection == "open") {
await delay(1000 * 10)
process.exit(0)
}
if (
connection === "close" &&
lastDisconnect &&
lastDisconnect.error &&
lastDisconnect.error.output.statusCode != 401
) {
qr()
}
})
session.ev.on('creds.update', saveCreds)
session.ev.on("messages.upsert", () => { })
}
qr()