Skip to content

Commit

Permalink
use mega instead of pastebin
Browse files Browse the repository at this point in the history
  • Loading branch information
Guru322 committed Sep 15, 2024
1 parent 14c6730 commit 22b6f37
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
39 changes: 23 additions & 16 deletions lib/makesession.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import { fileURLToPath } from 'url'
import path from 'path'
import { writeFileSync } from 'fs'
import { BufferJSON } from '@whiskeysockets/baileys'
import PastebinAPI from 'pastebin-js'
let pastebin = new PastebinAPI('bR1GcMw175fegaIFV2PfignYVtF0b_Bl')
import { fileURLToPath } from 'url';
import path from 'path';
import { writeFileSync } from 'fs';
import * as mega from 'megajs';

async function processTxtAndSaveCredentials(txt) {
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const pasteId = txt.replace('GuruBot~', '')
const megaCode = txt.replace('GuruAi~', '');
const megaUrl = `https://mega.nz/file/${megaCode}`;
console.log(megaUrl)

let decodedData = await pastebin.getPaste(pasteId)
const file = mega.File.fromURL(megaUrl);

try {
const credsPath = path.join(__dirname, '..', 'session', 'creds.json')
writeFileSync(credsPath, decodedData.toString())
console.log('Saved credentials to', credsPath)
} catch (jsonError) {
console.error('Error parsing JSON:', jsonError)
const stream = file.download();
let data = '';

for await (const chunk of stream) {
data += chunk.toString();
}

const credsPath = path.join(__dirname, '..', 'session', 'creds.json');
writeFileSync(credsPath, data);
console.log('Saved credentials to', credsPath);
} catch (error) {
console.error('Error downloading or saving credentials:', error);
}
}

export default processTxtAndSaveCredentials
export default processTxtAndSaveCredentials;
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"license": "Apache License 2.0",
"dependencies": {
"@adiwajshing/keyed-db": "^0.2.4",
"@bochilteam/scraper": "^5.0.1",
"@bochilteam/scraper": "*",
"@google/generative-ai": "0.1.3",
"@shineiichijo/marika": "^2.0.6",
"@vitalets/google-translate-api": "^9.2.0",
Expand Down Expand Up @@ -81,13 +81,12 @@
"link-preview-js": "^3.0.0",
"lodash": "^4.17.21",
"lowdb": "^3.0.0",
"megajs": "^1.1.4",
"megajs": "^1.3.1",
"moment-timezone": "^0.5.37",
"mongoose": "^7.4.1",
"node-fetch": "^3.3.1",
"node-gtts": "^2.0.2",
"node-webpmux": "^3.1.3",
"pastebin-js": "^1.0.6",
"pdfkit": "^0.13.0",
"perf_hooks": "^0.0.1",
"pino": "^8.6.1",
Expand Down

0 comments on commit 22b6f37

Please sign in to comment.