-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Athena's Shield | The Extra File Verification System #364
base: master
Are you sure you want to change the base?
Changes from 39 commits
3ee4c73
9813802
5f3e229
3790b52
85cb733
7073c27
886b29e
1476dbb
2fc9c3e
b435f7a
e3c6a18
ae9e7b5
fc5a2d4
96e0ca1
297a3a0
9d4c8cc
4835001
1f4df6b
980c836
0964648
3cdad51
485facf
33788d4
84b4ba9
f366b8b
50ad0e8
a94aa49
1515571
db49984
1608983
a9c81a1
d0c5bf1
5ffa732
068ca6b
a8a00e4
aab9ff5
8744d3b
0893cf5
f0321e1
0348e83
f68165c
040ca97
aef5e02
1614b63
93bca16
bd67015
e51eefa
745a11e
4732ee5
d659e0f
07ed316
7f33a1d
2f0a054
d4437c7
0770d65
092f36a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
const fs = require('fs') | ||
const readline = require('readline') | ||
const path = require('path') | ||
|
||
// Path to the configuration file | ||
const configPath = path.join(__dirname, 'variables.athshield') | ||
|
||
// Load the variables from the file | ||
function loadConfig() { | ||
const rawData = fs.readFileSync(configPath) | ||
return JSON.parse(rawData.toString()) // Convert Buffer to string | ||
} | ||
|
||
// Save the variables to the file | ||
function saveConfig(config) { | ||
const data = JSON.stringify(config, null, 2) | ||
fs.writeFileSync(configPath, data) | ||
} | ||
|
||
// Create the readline interface | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}) | ||
|
||
// Function to ask questions to the user | ||
function startCLI() { | ||
const config = loadConfig() | ||
|
||
rl.question('Would you like to activate Athena\'s Shield? (yes/no): ', (answer) => { | ||
if (answer.trim().startsWith('//')) { | ||
console.log('This is a comment; the line is ignored.') | ||
rl.close() | ||
return | ||
} | ||
|
||
if (answer.toLowerCase() === 'yes') { | ||
config.athenaShieldActivated = true | ||
|
||
rl.question('Would you like to activate debug mode? (yes/no): ', (debugAnswer) => { | ||
config.debug = debugAnswer.toLowerCase() === 'yes' // Set debug to true or false | ||
|
||
rl.question('Would you like to hide or block the menu? (hide/block): ', (menuAnswer) => { | ||
if (menuAnswer.trim().startsWith('//')) { | ||
console.log('This is a comment; the line is ignored.') | ||
rl.close() | ||
return | ||
} | ||
|
||
if (menuAnswer.toLowerCase() === 'hide') { | ||
config.menuVisibility = 'hidden' // Set to 'hidden' | ||
console.log('Athena\'s Shield activated. Menu hidden.') | ||
} else if (menuAnswer.toLowerCase() === 'block') { | ||
config.menuVisibility = 'blocked' // Set to 'blocked' | ||
console.log('Athena\'s Shield activated. Menu blocked.') | ||
} else { | ||
console.log('Invalid option for the menu.') | ||
rl.close() | ||
return | ||
} | ||
|
||
// Save the modified configuration | ||
saveConfig(config) | ||
rl.close() | ||
}) | ||
}) | ||
} else if (answer.toLowerCase() === 'no') { | ||
console.log('Athena\'s Shield not activated. Closing the CLI.') | ||
config.athenaShieldActivated = false | ||
config.menuVisibility = 'visible' // Reset to default | ||
config.debug = 'false' | ||
|
||
// Save the modified configuration | ||
saveConfig(config) | ||
rl.close() | ||
} else { | ||
console.log('Invalid response.') | ||
rl.close() | ||
} | ||
}) | ||
} | ||
|
||
// Launch the CLI | ||
startCLI() |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are the comments in french? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I started my code in French, but I had to translate it into English, and this is the only file I didn’t translate—a lapse in attention. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
// Chemin vers le fichier de configuration | ||
const configPath = path.join(__dirname, 'variables.athshield') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not simply use a json extension? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je vais faire en sorte d'utiliser un fichier json There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll make sure to use a JSON file. |
||
|
||
// Classe pour gérer Athena's Shield | ||
class AthenaShield { | ||
constructor() { | ||
this.config = this.loadConfig() | ||
} | ||
|
||
// Charger les variables depuis le fichier | ||
loadConfig() { | ||
const rawData = fs.readFileSync(configPath) | ||
return JSON.parse(rawData.toString()) | ||
} | ||
|
||
// Récupérer le statut d'Athena's Shield | ||
get status() { | ||
return this.config.athenaShieldActivated | ||
} | ||
|
||
// Récupérer la visibilité du menu | ||
get type() { | ||
return this.config.menuVisibility | ||
} | ||
|
||
// Récupérer le mode debug | ||
get debug() { | ||
return this.config.debug | ||
} | ||
} | ||
|
||
// Exporter une instance de la classe | ||
const athenaShieldInstance = new AthenaShield() | ||
module.exports = athenaShieldInstance |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,5 @@ | ||||||||||||||||||||||||
{ | ||||||||||||||||||||||||
"athenaShieldActivated": false, | ||||||||||||||||||||||||
"menuVisibility": "visible", | ||||||||||||||||||||||||
"debug": "false" | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, why not use a json file
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it about the JSON file, and I’ll add a line at the end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this belongs in the readme. I'd put it either in the docs folder, or in the wiki
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour ça si le code sera merge il faudra le faire mais pour l'instant je ne peux pas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For that, if the code is going to be merged, it will have to be done, but for now, I can’t.