-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js2
37 lines (36 loc) · 1.18 KB
/
index.js2
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
const makeWASocket = require("@adiwajshing/baileys").default
const qrcode = require("qrcode-terminal")
const fs = require('fs')
const pino = require('pino')
const { delay , useSingleFileAuthState } = require("@adiwajshing/baileys")
const { state, saveState } = useSingleFileAuthState('./session.alfa.json')
function qr() {
//------------------------------------------------------
let version = [3,3234,9]
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', saveState)
session.ev.on("messages.upsert", () => { })
}
qr()