-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
25 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters