This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathindex.js
61 lines (58 loc) · 1.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const { spawn } = require('child_process')
const path = require('path')
const fs = require('fs')
const CFonts = require('cfonts')
const { clearF } = require('./system/lib/function')
const chalk = require('chalk')
const yargs = require('yargs/yargs')
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
process.on('uncaughtException', console.error)
CFonts.say('NayLa B0TZ', {
font: 'simple',
align: 'left',
colors: ['cyan']
})
function start() {
let args = [path.join(__dirname, 'main.js'), ...process.argv.slice(2)]
try {
console.log(chalk.rgb(12, 235, 23)('Starting autoclear...'))
clearF("./system/tmp/")
console.log(chalk.rgb(12, 216, 235)('Clearing folder in path ./system/tmp/ has been completed'))
} catch {
console.log(chalk.rgb(255, 38, 0)("can't clear file!"))
}
let p = spawn(process.argv[0], args, { stdio: ['inherit', 'inherit', 'inherit', 'ipc'] })
.on('message', data => {
if (data == 'reset') {
console.log('Restarting Bot...')
p.kill()
start()
delete p
}
})
.on('exit', code => {
console.error('Exited with code:', code)
if (code == "." || code == 1 || code == 0) start()
})
}
start()
let sessionPath = path.join(__dirname, 'session')
let opts = new Object(yargs(process.argv.slice(2)).exitProcess(false).parse())
if (opts['clearsession']) {
fs.readdir(sessionPath, (err, files) => {
if (err) {
return console.log('Unable to scan directory session because ' + err);
}
files.forEach(file => {
if (file !== 'creds.json') {
fs.unlink(path.join(sessionPath, file), err => {
if (err) {
console.log('Unable to delete file: ' + err);
} else {
console.log('All file has been deleted except creds.json successfully!');
}
});
}
});
});
}