forked from Dissabot337/Dissa-SESSION-ID
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pair.js
137 lines (130 loc) ยท 6.15 KB
/
pair.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
const { makeid } = require('./gen-id');
const express = require('express');
const fs = require('fs');
let router = express.Router();
const pino = require("pino");
const { default: makeWASocket, useMultiFileAuthState, delay, Browsers, makeCacheableSignalKeyStore, getAggregateVotesInPollMessage, DisconnectReason, WA_DEFAULT_EPHEMERAL, jidNormalizedUser, proto, getDevice, generateWAMessageFromContent, fetchLatestBaileysVersion, makeInMemoryStore, getContentType, generateForwardMessageContent, downloadContentFromMessage, jidDecode } = require('@whiskeysockets/baileys')
const { upload } = require('./mega');
function removeFile(FilePath) {
if (!fs.existsSync(FilePath)) return false;
fs.rmSync(FilePath, { recursive: true, force: true });
}
router.get('/', async (req, res) => {
const id = makeid();
let num = req.query.number;
async function GIFTED_MD_PAIR_CODE() {
const {
state,
saveCreds
} = await useMultiFileAuthState('./temp/' + id);
try {
var items = ["Safari"];
function selectRandomItem(array) {
var randomIndex = Math.floor(Math.random() * array.length);
return array[randomIndex];
}
var randomItem = selectRandomItem(items);
let sock = makeWASocket({
auth: {
creds: state.creds,
keys: makeCacheableSignalKeyStore(state.keys, pino({ level: "fatal" }).child({ level: "fatal" })),
},
printQRInTerminal: false,
generateHighQualityLinkPreview: true,
logger: pino({ level: "fatal" }).child({ level: "fatal" }),
syncFullHistory: false,
browser: Browsers.macOS(randomItem)
});
if (!sock.authState.creds.registered) {
await delay(1500);
num = num.replace(/[^0-9]/g, '');
const code = await sock.requestPairingCode(num);
if (!res.headersSent) {
await res.send({ code });
}
}
sock.ev.on('creds.update', saveCreds);
sock.ev.on("connection.update", async (s) => {
const {
connection,
lastDisconnect
} = s;
if (connection == "open") {
await delay(5000);
let data = fs.readFileSync(__dirname + `/temp/${id}/creds.json`);
let rf = __dirname + `/temp/${id}/creds.json`;
function generateRandomText() {
const prefix = "3EB";
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let randomText = prefix;
for (let i = prefix.length; i < 22; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
randomText += characters.charAt(randomIndex);
}
return randomText;
}
const randomText = generateRandomText();
try {
const { upload } = require('./mega');
const mega_url = await upload(fs.createReadStream(rf), `${sock.user.id}.json`);
const string_session = mega_url.replace('https://mega.nz/file/', '');
let md = "Mercedes=" + string_session;
let code = await sock.sendMessage(sock.user.id, { text: md });
let desc = `*๐ณ๐๐๐ ๐๐๐๐๐ ๐๐๐๐ ๐๐๐๐ ๐ ๐๐๐ ๐๐๐ข๐๐๐!! ๐๐๐ ๐๐๐๐ ๐๐๐๐ ๐๐ ๐๐๐๐๐๐ Mercedes ๐๐๐๐๐๐๐๐ ๐๐๐๐ ๐๐๐.*\n\n โฆ *Github:* https://github.com/betingrich/Maserati`;
await sock.sendMessage(sock.user.id, {
text: desc,
contextInfo: {
externalAdReply: {
title: "Mercedes",
thumbnailUrl: "https://telegra.ph/file/88c7e505240398b93e0fe.jpg",
sourceUrl: "https://whatsapp.com/channel/0029Vajvy2kEwEjwAKP4SI0x",
mediaType: 1,
renderLargerThumbnail: true
}
}
},
{quoted:code })
} catch (e) {
let ddd = sock.sendMessage(sock.user.id, { text: e });
let desc = `*๐ณ๐๐๐ ๐๐๐๐๐ ๐๐๐๐ ๐๐๐๐ ๐ ๐๐๐ ๐๐๐ข๐๐๐!! ๐๐๐ ๐๐๐๐ ๐๐๐๐ ๐๐ ๐๐๐๐๐๐ Mercedes ๐๐๐๐๐๐๐๐ ๐๐๐๐ ๐๐๐.*\n\n โฆ *Github:* https://github.com/betingrich/Maserati`;
await sock.sendMessage(sock.user.id, {
text: desc,
contextInfo: {
externalAdReply: {
title: "Mercedes",
thumbnailUrl: "https://telegra.ph/file/88c7e505240398b93e0fe.jpg",
sourceUrl: "https://whatsapp.com/channel/0029Vajvy2kEwEjwAKP4SI0x",
mediaType: 2,
renderLargerThumbnail: true,
showAdAttribution: true
}
}
},
{quoted:ddd })
}
await delay(10);
await sock.ws.close();
await removeFile('./temp/' + id);
console.log(`๐ค ${sock.user.id} ๐๐ผ๐ป๐ป๐ฒ๐ฐ๐๐ฒ๐ฑ โ
๐ฅ๐ฒ๐๐๐ฎ๐ฟ๐๐ถ๐ป๐ด ๐ฝ๐ฟ๐ผ๐ฐ๐ฒ๐๐...`);
await delay(10);
process.exit();
} else if (connection === "close" && lastDisconnect && lastDisconnect.error && lastDisconnect.error.output.statusCode != 401) {
await delay(10);
GIFTED_MD_PAIR_CODE();
}
});
} catch (err) {
console.log("service restated");
await removeFile('./temp/' + id);
if (!res.headersSent) {
await res.send({ code: "โ Service Unavailable" });
}
}
}
return await GIFTED_MD_PAIR_CODE();
});/*
setInterval(() => {
console.log("โ๏ธ ๐ฅ๐ฒ๐๐๐ฎ๐ฟ๐๐ถ๐ป๐ด ๐ฝ๐ฟ๐ผ๐ฐ๐ฒ๐๐...");
process.exit();
}, 180000); //30min*/
module.exports = router;