generated from Fujikaze-njn/Session-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqr.js
98 lines (93 loc) · 2.92 KB
/
qr.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const PastebinAPI = require('pastebin-js'),
pastebin = new PastebinAPI('EMWTMkQAVfJa9kM-MRUrxd5Oku1U7pgL')
const {makeid} = require('./id');
const QRCode = require('qrcode');
const express = require('express');
const path = require('path');
const fs = require('fs');
let router = express.Router()
const pino = require("pino");
const {
default: Maher_Zubair,
useMultiFileAuthState,
jidNormalizedUser,
Browsers,
delay,
makeInMemoryStore,
} = require("maher-zubair-baileys");
function removeFile(FilePath) {
if (!fs.existsSync(FilePath)) return false;
fs.rmSync(FilePath, {
recursive: true,
force: true
})
};
const {
readFile
} = require("node:fs/promises")
router.get('/', async (req, res) => {
const id = makeid();
async function SIGMA_MD_QR_CODE() {
const {
state,
saveCreds
} = await useMultiFileAuthState('./temp/' + id)
try {
let Qr_Code_By_Maher_Zubair = Maher_Zubair({
auth: state,
printQRInTerminal: false,
logger: pino({
level: "silent"
}),
browser: Browsers.macOS("Desktop"),
});
Qr_Code_By_Maher_Zubair.ev.on('creds.update', saveCreds)
Qr_Code_By_Maher_Zubair.ev.on("connection.update", async (s) => {
const {
connection,
lastDisconnect,
qr
} = s;
if (qr) await res.end(await QRCode.toBuffer(qr));
if (connection == "open") {
await delay(5000);
let data = fs.readFileSync(__dirname + `/temp/${id}/creds.json`);
await delay(800);
let b64data = Buffer.from(data).toString('base64');
let session = await Pair_Code_By_Maher_Zubair.sendMessage(Pair_Code_By_Maher_Zubair.user.id, { text: data });
let SIGMA_MD_TEXT = `
_*PAIR Successful 🔥*_
put the above ID in the sessID variable when deploying .
Use this Session ID for all bots by STAR KING.
╔═════◇
║ 『••• STAR KING•••』
║ *Channel:* _https://whatsapp.com/channel/0029VaeW5Tw4yltQOYIO5E2D_
║ *Main GC:* _https://chat.whatsapp.com/DC38hUUVVaa1vp573QBYBF_
║ *Github:* _https://github.com/STAR-KING0_
║ *Owner:* _https://wa.me/2348100835767_
║ *Note :*_Do not provide your SESSION_ID to_
║ _anyone otherwise that can access your WA messages_
║ _*Follow Me and Star my repo for more 🫡.*_
╚════════════════════════╝`
await Pair_Code_By_Maher_Zubair.sendMessage(Pair_Code_By_Maher_Zubair.user.id,{text:SIGMA_MD_TEXT},{quoted:session})
await delay(100);
await Qr_Code_By_Maher_Zubair.ws.close();
return await removeFile("temp/" + id);
} else if (connection === "close" && lastDisconnect && lastDisconnect.error && lastDisconnect.error.output.statusCode != 401) {
await delay(10000);
SIGMA_MD_QR_CODE();
}
});
} catch (err) {
if (!res.headersSent) {
await res.json({
code: "Service Unavailable"
});
}
console.log(err);
await removeFile("temp/" + id);
}
}
return await SIGMA_MD_QR_CODE()
});
module.exports = router