forked from BOTCAHX/Session-MD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (41 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
33
34
35
36
37
38
39
40
41
42
var makeWASocket = require("@adiwajshing/baileys").default
var qrcode = require("qrcode-terminal");
var {
delay,
useSingleFileAuthState
} = require("@adiwajshing/baileys");
var {
state,
saveState
} = useSingleFileAuthState('./X.data.json')
function qr() {
var session = makeWASocket({
auth: state,
printQRInTerminal: true,
browser: ['baileys', 'Chrome', ''],
connectTimeoutMs: 60_000,
defaultQueryTimeoutMs: 0,
keepAliveIntervalMs: 1000
})
session.ev.on("connection.update", async (s) => {
var {
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()