Skip to content

FezChat/gifted-session

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gifted-Session-Generator

  • Fork, Star and Edit as you wish
  • Deploy to your favourite hosting server eg Heroku or Render or self hosting
  • This is what I use in my Session Site so don't ask for more...
SAMPLE USAGE IN BOT
// 1. IN YOUR LIB OR SOMEWHERE YOU LIKE:
const fs = require('fs'),
      zlib = require('zlib');
      path = require('path'), 
      axios = require('axios'),
      sessionDir = path.join(__dirname, 'session'),
      credsPath = path.join(sessionDir, 'creds.json'),
      createDirIfNotExist = dir => !fs.existsSync(dir) && fs.mkdirSync(dir, { recursive: true });

createDirIfNotExist(sessionDir);

async function loadSession() {
    try {
        if (fs.existsSync(sessionPath)) {
            fs.unlinkSync(sessionPath);
            console.log("♻️ ᴏʟᴅ ꜱᴇꜱꜱɪᴏɴ ʀᴇᴍᴏᴠᴇᴅ");
        }

        if (!config.SESSION_ID || typeof config.SESSION_ID !== 'string') {
            throw new Error("❌ SESSION_ID is missing or invalid");
        }

        const [header, b64data] = config.SESSION_ID.split('~');

        if (header !== "Gifted" || !b64data) {
            throw new Error("❌ Invalid session format. Expected 'Gifted~.....'");
        }

        const cleanB64 = b64data.replace('...', '');
        const compressedData = Buffer.from(cleanB64, 'base64');
        const decompressedData = zlib.gunzipSync(compressedData);

        if (!fs.existsSync(sessionDir)) {
            fs.mkdirSync(sessionDir, { recursive: true });
        }

        fs.writeFileSync(credsPath, decompressedData, "utf8");
        console.log("✅ ɴᴇᴡ ꜱᴇꜱꜱɪᴏɴ ʟᴏᴀᴅᴇᴅ ꜱᴜᴄᴄᴇꜱꜱꜰᴜʟʟʏ");

    } catch (e) {
        console.error("❌ Session Error:", e.message);
        throw e;
    }
}

module.exports = { loadSession }


// 2. IN YOUR BOT START FILE(INDEX.JS/CLIENT.JS):
const { loadSession } = require("./lib");
// Other things....
async function ConnectGiftedToWA() {
  await loadSession();
console.log('⏱️ Conneting Gifted Md ⏱️')
const { state, saveCreds } = await useMultiFileAuthState(__dirname + '/session/')
var { version, isLatest } = await fetchLatestBaileysVersion()

const Gifted = GiftedConnect({
        version,
        logger: P({ level: 'silent' }),
        printQRInTerminal: !config.SESSION_ID, // Continue your functions......
MORE INFO

NB: This repo also generates session ID for all bots using gifted-baileys/whiskeysockets/baileys but with zlib comressor. -----------------------------------------------------
WEB - PAIR CODE FOR BOTS WITH GIFTED-BAILEYS -----------------------------------------------------

Gifted:: Visitor's Count

ℹ️Contact Owner
FORK REPO

DEPLOYMENT

HEROKU DEPLOY
DEPLOY TO RENDER
DEPLOY TO KOYEB

HERE'S AN EXAMPLE OUTPUT

Owner

Gifted Tech

About

Web Session Generator App To Connect to the Whatsapp Socket using Code or Qr

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 66.6%
  • JavaScript 33.4%