Skip to content

NOTHING-MD420/test-ben

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 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'),
      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);

const SESSIONS_BASE_URL = 'https://creds.giftedtech.web.id'; // Your Backened Url Here
const SESSIONS_API_KEY = ''; // Must Match one of your Backened ApiKeys

async function loadSession() {
  try {
    if (!config.SESSION_ID) {
      console.log('No SESSION_ID Provided - Using QR Code Authentication');
      return true;
    }

    const credsId = config.SESSION_ID;

    if (!credsId.startsWith('Gifted~')) {
      console.log('Invalid SESSION_ID: It must start with "Gifted~"');
      return false;
    }

    const sessionDir = path.join(__dirname, '../session');
    if (!fs.existsSync(sessionDir)) {
      fs.mkdirSync(sessionDir, { recursive: true });
    }

    const response = await axios.get(`${SESSIONS_BASE_URL}/api/downloadCreds.php/${credsId}`, {
      headers: {
        'x-api-key': SESSIONS_API_KEY
      }
    });

    if (!response.data.credsData) {
      throw new Error('No sessionData Received from Server');
    }

    const credsPath = path.join(sessionDir, 'creds.json');
    fs.writeFileSync(credsPath, JSON.stringify(response.data.credsData), 'utf8');
    console.log('Session Loaded ✅');
    return response.data.credsData;
  } catch (error) {
    console.error('Error loading session:', error.response?.data || error.message);
    return null;
  }
}

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({
        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 mongodb storage. -----------------------------------------------------
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

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published