-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.js
112 lines (104 loc) · 7.35 KB
/
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
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
/*
//══════════════════════════════════════════════════════════════════════════════════════════════════════//
// //
// WHATSAPP BOT-MD BETA //
// //
// V:1.0.1 //
// //
// ███████╗██╗ ██╗██╗ ██╗ █████╗ ██╗██╗ ███╗ ███╗██████╗ //
// ██╔════╝██║ ██║██║ ██║██╔══██╗██║██║ ████╗ ████║██╔══██╗ //
// ███████╗██║ ██║███████║███████║██║██║ ██╔████╔██║██║ ██║ //
// ╚════██║██║ ██║██╔══██║██╔══██║██║██║ ██║╚██╔╝██║██║ ██║ //
// ███████║╚██████╔╝██║ ██║██║ ██║██║███████╗ ██║ ╚═╝ ██║██████╔╝ //
// ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚══════╝ ╚═╝ ╚═╝╚═════╝ //
// //
// //
// //
//══════════════════════════════════════════════════════════════════════════════════════════════════════//
CURRENTLY RUNNING ON BETA VERSION!!
*
* @project_name : baileys-qr
* @author : Suhail Tech Info
* @youtube : https://www.youtube.com/SuhailTechInfo
* @description : Get baileys qr, where session id Converted into 'base64'. You can change it According to your needs.
* @version 1.0.0
*
* Licensed under the GPL-3.0 License;
*
* Created By Suhail Tech Info.
* © 2023 Suhail-Md.
*/
const fs = require("fs-extra");
const pino = require("pino");
let qrcode = require("qrcode-terminal");
if (fs.existsSync('./auth_info_baileys')) {
fs.emptyDirSync(__dirname + '/auth_info_baileys');
require('child_process').exec('rm -rf auth_info_baileys')
console.log('\nPlease Wait... Removing Cache files');
setTimeout(() => { console.log(' ') }, 100);
setTimeout(() => { console.log('Q') }, 300);
setTimeout(() => { console.log('R') }, 500);
setTimeout(() => { console.log(' ') }, 700);
setTimeout(() => { console.log('B') }, 900);
setTimeout(() => { console.log('Y') }, 1100);
setTimeout(() => { console.log(' ') }, 1300);
setTimeout(() => { console.log('S') }, 1500);
setTimeout(() => { console.log('U') }, 1700);
setTimeout(() => { console.log('H') }, 1900);
setTimeout(() => { console.log('A') }, 2100);
setTimeout(() => { console.log('I') }, 2300);
setTimeout(() => { console.log('L') }, 2500);
setTimeout(() => { console.log(' ') }, 2700);
setTimeout(() => { console.log('Cache Cleared..!\nRun The Script Again') }, 2900);
setTimeout(() => { process.exit() }, 3000)
};
setTimeout(() => {
const { default: makeWASocket, useMultiFileAuthState, Browsers, delay, makeInMemoryStore, } = require("@sampandey001/baileys");
const store = makeInMemoryStore({ logger: pino().child({ level: 'silent', stream: 'store' }) })
async function sᴜʜᴀɪʟ_ʙᴀɪʟᴇʏs_ǫʀ() {
const { state, saveCreds } = await useMultiFileAuthState(__dirname + '/auth_info_baileys')
try {
let session = makeWASocket({ printQRInTerminal: true, logger: pino({ level: "silent" }), browser: Browsers.macOS("Desktop"), auth: state });
session.ev.on("connection.update", async (s) => {
const { connection, lastDisconnect, qr } = s;
if (connection == "open")
{
await delay(500);
let user = session.user.id; // User = Number of that user who just Scanned the Qr
//===========================================================================================
//=============================== SESSION ID =============================================
//===========================================================================================
let unique = fs.readFileSync(__dirname + '/auth_info_baileys/creds.json') //GETTING CREDS FROM CREDS.json TO GENERATE SESSION ID
c = Buffer.from(unique).toString('base64'); // CHANGE 'base64' ACCORDING TO YOUR NEEDS
console.log(`
==================== SESSION ID ===========================
SESSION-ID ==> ${c}\n\n
Don't provide your SESSION_ID to anyone otherwise that user can access your account.
Thanks.
------------------- SESSION CLOSED -----------------------
`)
let cc = `╔════◇
║『 *THANKS FOR CHOOSING SUHAIL-MD* 』
║ _You complete first step to making Bot._
╚════════════════════════╝
╔═════◇
║ 『••• 𝗩𝗶𝘀𝗶𝘁 𝗙𝗼𝗿 𝗛𝗲𝗹𝗽 •••』
║ *1.Github:* _github.com/suhailtechinfo_
║ *2.Ytube:* _youtube.com/suhailtechinfo_
║ *3.Owner:* _https://wa.me/923184474176_
║ *Note :*_Don't provide your SESSION_ID to_
║ _anyone otherwise that can access chats_
╚════════════════════════╝
`;
let session_id = await session.sendMessage(user, { text: c }); //SENDING 'base64' SESSION ID TO USER NUMBER
await session.sendMessage(user, { text: cc } , { quoted : session_id });
await require('child_process').exec('rm -rf auth_info_baileys') //CLEAR 'auth_info_baileys' SO THAT NEXT TIME IT CLEARED FOR SCANNING
process.exit(1) // STOPPING PROCESS AFTER GETTING SESSION ID
}
session.ev.on('creds.update', saveCreds)
if (connection === "close" && lastDisconnect && lastDisconnect.error && lastDisconnect.error.output.statusCode != 401) { sᴜʜᴀɪʟ_ʙᴀɪʟᴇʏs_ǫʀ(); } // IF ANY ERROR< THEN PRINT QR AGAIN
});
} catch (err) {console.log(err);await require('child_process').exec('rm -rf auth_info_baileys');process.exit(1);}
}
sᴜʜᴀɪʟ_ʙᴀɪʟᴇʏs_ǫʀ();
}, 3000)