Skip to content

Commit

Permalink
Just break a thing, now its fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
rubencosta13 committed Dec 19, 2021
1 parent a460fc4 commit 60eab92
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 40 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
.env
.env
tempFiles.exe
34 changes: 17 additions & 17 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ name="Ruben Lavos Costa"
discord="Ruben Costa#4242"

[PlaceHolders]
discordUsername="" #E.G. File Cleaner
embedTitle="" #E.G. Temporary File Cleaner
embedColor="" #Ckeck Colors on the bottom -> Use Int Value
discordUsername="Testing" #E.G. File Cleaner
embedTitle="awd" #E.G. Temporary File Cleaner
embedColor=1752220 #Ckeck Colors on the bottom -> Use Int Value
os_placeholder="" #E.G. Operating System:
os_hostname="" #E.G. Hostname: [On my organization we chnaged the computer hostname for the internet switch port's number]
cpu_core="" #E.G CPU cores:
free_ram="" #E.G. Free RAM:
available_ram="" #E.G. Available RAM:
uptime="" #E.G. Uptime:
cpu_percentage="" #E.G. CPU usage [On the code it ads the percentatge symbol itself]
c_drive_usage="" #E.G. C drive usage: [On the code it ads the percentatge symbol itself]
disk_cleanup="" #E.G. C drive needs to be cleaned up: [It will only show if the drive is higher than 70% used]
temporary_files_cleaned ="" #E.G. Temporary files Cleaned!
error="" #E.G. Error:
computer="" #E.G. Computer:
not_updated="" #E.G. New version available: https://github.com/rubencosta13/Temporary-files-cleaner
os_hostname="adw" #E.G. Hostname: [On my organization we chnaged the computer hostname for the internet switch port's number]
cpu_core="awd" #E.G CPU cores:
free_ram="awd" #E.G. Free RAM:
available_ram="awd" #E.G. Available RAM:
uptime="adw" #E.G. Uptime:
cpu_percentage="awd" #E.G. CPU usage [On the code it ads the percentatge symbol itself]
c_drive_usage="awd" #E.G. C drive usage: [On the code it ads the percentatge symbol itself]
disk_cleanup="awd" #E.G. C drive needs to be cleaned up: [It will only show if the drive is higher than 70% used]
temporary_files_cleaned ="awd" #E.G. Temporary files Cleaned!
error="adw" #E.G. Error:
computer="awd" #E.G. Computer:
not_updated="adw" #E.G. New version available: https://github.com/rubencosta13/Temporary-files-cleaner

[Variables]
discord_logger="" #Webhook where all the infos are logged on
discord_error="" #Webhook where all the errors are shown
discord_logger=https://discord.com/api/webhooks/922133046973571113/OR6hb-hilbl_2ThqrjOsJZd4IGIiq9ws4-qTvcAzI4u16r1YdqMKKuTAJm4RN1O_NdAX #Webhook where all the infos are logged on
discord_error=https://discord.com/api/webhooks/922133046973571113/OR6hb-hilbl_2ThqrjOsJZd4IGIiq9ws4-qTvcAzI4u16r1YdqMKKuTAJm4RN1O_NdAX #Webhook where all the errors are shown

[Colors]
Name | Int value | Hex Code |
Expand Down
37 changes: 18 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import osu from 'node-os-utils'
import os from 'os'
import axios from 'axios'
import rimraf from 'rimraf'
import nodeDiskInfo from 'node-disk-info'
import fs from 'fs'
import ini from 'ini'
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
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 location = __dirname + "\\config.ini"
console.log(location)


const cpu = osu.cpu
Expand All @@ -20,6 +18,7 @@ const temp2 = `C:\\Users\\${username}\\AppData\\Local\\Temp`
const prefetch = `C:\\Windows\\Prefetch`
const config = ini.parse(fs.readFileSync(location, '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')
Expand All @@ -34,7 +33,7 @@ function checkVersion(){
}

function newUpdate(){
axios.post(config.Variables.discord_error , {
axios.post(`https://discord.com/api/webhooks/922133046973571113/OR6hb-hilbl_2ThqrjOsJZd4IGIiq9ws4-qTvcAzI4u16r1YdqMKKuTAJm4RN1O_NdAX` , {
"username": config.PlaceHolders.discordUsername,
"avatar_url": "",
"content": "",
Expand Down Expand Up @@ -70,14 +69,14 @@ try {
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,
axios.post(`https://discord.com/api/webhooks/922133046973571113/OR6hb-hilbl_2ThqrjOsJZd4IGIiq9ws4-qTvcAzI4u16r1YdqMKKuTAJm4RN1O_NdAX`, {
"username": `config.PlaceHolders.discordUsername`,
"avatar_url": "",
"content": "",
"embeds": [
{
"title": config.PlaceHolders.embedTitle,
"color": config.PlaceHolders.embedColor,
"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": {},
Expand All @@ -93,13 +92,13 @@ try {
})
}else{
axios.post(process.env.DISCORD_LOGGER, {
"username": config.PlaceHolders.discordUsername,
"username": `config.PlaceHolders.discordUsername`,
"avatar_url": "",
"content": "",
"embeds": [
{
"title": config.PlaceHolders.embedTitle,
"color": config.PlaceHolders.embedColor,
"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": {},
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"name": "tempfies",
"version": "1.0.0",
"description": "",
"type": "module",
"main": "limparFicheiros.js",
"main": "index.js",
"scripts": {
"build": "nexe -t x64-8.0.0",
"run": "node --experimental-json-modules index.js",
Expand Down
2 changes: 1 addition & 1 deletion version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"2.0.0"
2.0.0

0 comments on commit 60eab92

Please sign in to comment.