-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
133 lines (128 loc) · 6.19 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const osu = require('node-os-utils')
const os = require('os')
const axios = require('axios')
const rimraf = require('rimraf')
const nodeDiskInfo = require('node-disk-info')
const fs = require('fs')
const ini = require('ini')
const cpu = osu.cpu
const date = new Date()
const username = os.userInfo().username
const temp = `C:\\Windows\\Temp`
const temp2 = `C:\\Users\\${username}\\AppData\\Local\\Temp`
const prefetch = `C:\\Windows\\Prefetch`
const config = ini.parse(fs.readFileSync(__dirname+'\\config.ini', 'utf-8'));
function checkVersion(){
const currentVersion = fs.readFileSync(__dirname+'\\version.js', 'utf-8')
const githubVersion = axios.get('https://raw.githubusercontent.com/rubencosta13/Temporary-files-cleaner/master/version.js')
.then(response => {
if (currentVersion !== githubVersion){
console.log(`New version available!`)
newUpdate()
}
})
}
function newUpdate(){
axios.post(config.Variables.discord_logger, {
"username": config.PlaceHolders.discordUsername,
"avatar_url": "",
"content": "",
"embeds": [
{
"title": config.PlaceHolders.embedTitle,
"color": config.PlaceHolders.embedColor,
"description": config.PlaceHolders.not_updated,
"timestamp": null,
"author": {},
"image": {},
"thumbnail": {},
"footer": {
"text": `Made by: Ruben Costa#4242 | ${date.toISOString()} ${config.PlaceHolders.footerText}`
},
"fields": []
}
],
"components": []
})
}
try {
checkVersion()
let percentage = 0
cpu.usage()
.then(cpuPercentage => {
nodeDiskInfo.getDiskInfo()
.then(disks => {
percentage == cpuPercentage
rimraf(temp, function () {});
rimraf(temp2, function () {});
rimraf(prefetch, function () {});
if ((100 * disks[0].used) / disks[0].blocks >= 70){
axios.post(config.Variables.discord_logger, {
"username": config.PlaceHolders.discordUsername,
"avatar_url": "",
"content": "",
"embeds": [
{
"title": config.PlaceHolders.embedTitle,
"color": config.PlaceHolders.embedColor, // config.PlaceHolders.os_placeholder +`${os.type()}\n`+config.PlaceHolders.os_hostname+`${os.hostname()}\n`+config.PlaceHolders.cpu_core+`${os.cpus().length}\n`+config.PlaceHolders.free_ram+`${Math.floor(os.freemem().toFixed(2))} Mb\n`+config.PlaceHolders.available_ram+`${Math.floor(os.totalmem().toFixed(2))} Mb\n`+config.PlaceHolders.uptime+`${os.uptime()} seconds\n`+config.PlaceHolders.cpu_percentage+`${cpuPercentage}%\n`+config.PlaceHolders.c_drive_usage+`${disks[0].capacity}\n\n`+config.PlaceHolders.temporary_files_cleaned
"description": config.PlaceHolders.os_placeholder +` ${os.type()}\n`+config.PlaceHolders.os_hostname+` ${os.hostname()}\n`+config.PlaceHolders.cpu_core+` ${os.cpus().length}\n`+config.PlaceHolders.free_ram+` ${Math.floor(os.freemem().toFixed(2))} Mb\n`+config.PlaceHolders.available_ram+` ${Math.floor(os.totalmem().toFixed(2))} Mb\n`+config.PlaceHolders.uptime+` ${os.uptime()} seconds\n`+config.PlaceHolders.cpu_percentage+` ${cpuPercentage}%\n`+config.PlaceHolders.c_drive_usage+` ${disks[0].capacity}\n\n`+config.PlaceHolders.temporary_files_cleaned,
"timestamp": null,
"author": {},
"image": {},
"thumbnail": {},
"footer": {
"text": `Made by: Ruben Costa#4242 | ${date.toISOString()} ${config.PlaceHolders.footerText}`
},
"fields": []
}
],
"components": []
})
}else{
axios.post(config.Variables.discord_logger, {
"username": config.PlaceHolders.discordUsername,
"avatar_url": "",
"content": "",
"embeds": [
{
"title": config.PlaceHolders.embedTitle,
"color": config.PlaceHolders.embedColor, //config.PlaceHolders.os_placeholder +`${os.type()}\n`+config.PlaceHolders.os_hostname+`${os.hostname()}\n`+config.PlaceHolders.cpu_core+`${os.cpus().length}\n`+config.PlaceHolders.free_ram+`${Math.floor(os.freemem().toFixed(2))} Mb\n`+config.PlaceHolders.available_ram+`${Math.floor(os.totalmem().toFixed(2))} Mb\n`+config.PlaceHolders.uptime+`${os.uptime()} seconds\n`+config.PlaceHolders.cpu_percentage+`${cpuPercentage}%\n`+config.PlaceHolders.c_drive_usage+`${disks[0].capacity}\n\n`+config.PlaceHolders.temporary_files_cleaned+"\n\n"+config.PlaceHolders.disk_cleanup
"description": config.PlaceHolders.os_placeholder + `${os.type()}\n`+config.PlaceHolders.os_hostname+` ${os.hostname()}\n`+config.PlaceHolders.cpu_core+` ${os.cpus().length}\n`+config.PlaceHolders.free_ram+` ${Math.floor(os.freemem().toFixed(2))} Mb\n`+config.PlaceHolders.available_ram+` ${Math.floor(os.totalmem().toFixed(2))} Mb\n`+config.PlaceHolders.uptime+` ${os.uptime()} seconds\n`+config.PlaceHolders.cpu_percentage+` ${cpuPercentage}%\n`+config.PlaceHolders.c_drive_usage+` ${disks[0].capacity}\n\n`+config.PlaceHolders.temporary_files_cleaned+"\n\n"+config.PlaceHolders.disk_cleanup,
"timestamp": null,
"author": {},
"image": {},
"thumbnail": {},
"footer": {
"text": `Made by: Ruben Costa#4242 | ${date.toISOString()} ${config.PlaceHolders.footerText}`
},
"fields": []
}
],
"components": []
})
}
})
})
} catch (e) {
axios.post(config.Variables.discord_error , {
"username": config.PlaceHolders.discordUsername,
"avatar_url": "",
"content": "",
"embeds": [
{
"title": config.PlaceHolders.embedTitle,
"color": config.PlaceHolders.embedColor,
"description": config.PlaceHolders.error+` ${e.message}\n`+ config.PlaceHolders.computer +`${os.hostname()}`,
"timestamp": null,
"author": {},
"image": {},
"thumbnail": {},
"footer": {
"text": `Made by: Ruben Costa#4242 | ${date.toISOString()} ${config.PlaceHolders.footerText}`
},
"fields": []
}
],
"components": []
})
}