Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/globaltechinfo/pairing-web

Session Id Generator For WhatsApp Bots
https://github.com/globaltechinfo/pairing-web

baileys baileys-api baileys-bot baileys-md express-pairing express-session pair pairing qr-code qrcode qrcode-generator qrcode-scanner web-qr whatsapp whatsapp-api whatsapp-bot

Last synced: 5 days ago
JSON representation

Session Id Generator For WhatsApp Bots

Awesome Lists containing this project

README

        

# Session Id Generator For WhatsApp Bots Using Paste Bin

**It Will Uploads Your Creds To Pastebin And Will Sends You Id Of That File.**

**How Session Id Will Works?**

Click Here To View?

```js
import { fileURLToPath } from 'url';
import path from 'path';
import { writeFileSync } from 'fs';
import axios from 'axios'; // use axios to fetch raw Pastebin data

async function SaveCreds(txt) {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const PasteId = txt.replace('Some-Custom-Words_', '');

// The 'txt' parameter should contain the Pastebin Id
const pastebinUrl = `https://pastebin.com/raw/${PasteId}`; // Construct raw Pastebin URL
console.log(`PASTE URL: ${pastebinUrl}`);

try {
// Fetch the raw data from Pastebin
const response = await axios.get(pastebinUrl);

// Ensure the data is a string or Buffer
const data = typeof response.data === 'string' ? response.data : JSON.stringify(response.data);

// Define the path to save the creds.json file in the session folder
const credsPath = path.join(__dirname, '..', 'session', 'creds.json');

// Write the fetched data to creds.json
writeFileSync(credsPath, data);
console.log('Saved credentials to', credsPath);

} catch (error) {
console.error('Error downloading or saving credentials:', error);
}
}

export default SaveCreds;

// Exports the `SaveCreds` function as the default export of this module, making it available for use in main file.

//Now Import Function In Main File
dotenv.config()
import SaveCreds from './some-file.js'

async function main() {
const txt = process.env.SESSION_ID

if (!txt) {
console.error('Environment variable not found.')
return
}

try {
await SaveCreds(txt)
console.log('process SaveCreds completed.')
} catch (error) {
console.error('Error:', error)
}
}

main()
// Now Use Further code
```

BOTH PAIR CODE AND QR CODE WORKING

YOU CAN DEPLOY IT ON ANY CLOUD PLATFORM e.g `HEROKU` `RENDER` `KOYEB` etc.

⭐ THE REPO IF YOU ARE GOING TO COPY OR FORK

Note: Make Sure Put PASTEBIN_API_KEY in environment variables ( Required In Paste.js ) Before Running/Deploying The API.

## OTHER PROJECTS:

- [MEGA SESSION](https://github.com/GlobalTechInfo/WEB-PAIR-QR)
- [WHATSAPP BOT](https://github.com/GlobalTechInfo/MEGA-AI)
- [TELEGRAM BOT](https://github.com/GlobalTechInfo/TELEGRAM-AI#readme)

| [![Qasim Ali](https://github.com/GlobalTechInfo.png?size=100)](https://github.com/GlobalTechInfo) |
| --- |
| [Qasim Ali](https://github.com/GlobalTechInfo) |