2024-10-23 08:33:39 -07:00
|
|
|
const fs = require('fs')
|
|
|
|
const readline = require('readline')
|
|
|
|
const path = require('path')
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
// Path to the configuration file
|
2024-10-23 08:33:39 -07:00
|
|
|
const configPath = path.join(__dirname, 'variables.athshield')
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
// Load the variables from the file
|
2024-10-23 08:33:39 -07:00
|
|
|
function loadConfig() {
|
|
|
|
const rawData = fs.readFileSync(configPath)
|
2024-10-24 09:18:52 -07:00
|
|
|
return JSON.parse(rawData.toString()) // Convert Buffer to string
|
2024-10-23 08:33:39 -07:00
|
|
|
}
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
// Save the variables to the file
|
2024-10-23 08:33:39 -07:00
|
|
|
function saveConfig(config) {
|
|
|
|
const data = JSON.stringify(config, null, 2)
|
|
|
|
fs.writeFileSync(configPath, data)
|
|
|
|
}
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
// Create the readline interface
|
2024-10-23 08:33:39 -07:00
|
|
|
const rl = readline.createInterface({
|
|
|
|
input: process.stdin,
|
|
|
|
output: process.stdout
|
|
|
|
})
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
// Function to ask questions to the user
|
2024-10-23 08:33:39 -07:00
|
|
|
function startCLI() {
|
|
|
|
const config = loadConfig()
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
rl.question('Would you like to activate Athena\'s Shield? (yes/no): ', (answer) => {
|
2024-10-23 08:33:39 -07:00
|
|
|
if (answer.trim().startsWith('//')) {
|
2024-10-24 09:18:52 -07:00
|
|
|
console.log('This is a comment; the line is ignored.')
|
2024-10-23 08:33:39 -07:00
|
|
|
rl.close()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
if (answer.toLowerCase() === 'yes') {
|
2024-10-23 08:33:39 -07:00
|
|
|
config.athenaShieldActivated = true
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
rl.question('Would you like to hide or block the menu? (hide/block): ', (menuAnswer) => {
|
2024-10-23 08:33:39 -07:00
|
|
|
if (menuAnswer.trim().startsWith('//')) {
|
2024-10-24 09:18:52 -07:00
|
|
|
console.log('This is a comment; the line is ignored.')
|
2024-10-23 08:33:39 -07:00
|
|
|
rl.close()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
if (menuAnswer.toLowerCase() === 'hide') {
|
2024-10-24 09:17:46 -07:00
|
|
|
config.menuVisibility = 'hidden' // Change to 'hidden'
|
2024-10-24 09:20:36 -07:00
|
|
|
console.log('Athena\'s Shield activated. Menu hidden.')
|
2024-10-24 09:18:52 -07:00
|
|
|
} else if (menuAnswer.toLowerCase() === 'block') {
|
2024-10-24 09:17:46 -07:00
|
|
|
config.menuVisibility = 'blocked' // Change to 'blocked'
|
2024-10-24 09:20:36 -07:00
|
|
|
console.log('Athena\'s Shield activated. Menu blocked.')
|
2024-10-23 08:33:39 -07:00
|
|
|
} else {
|
2024-10-24 09:18:52 -07:00
|
|
|
console.log('Invalid option for the menu.')
|
2024-10-23 08:33:39 -07:00
|
|
|
rl.close()
|
2024-10-24 09:17:46 -07:00
|
|
|
return
|
2024-10-23 08:33:39 -07:00
|
|
|
}
|
2024-10-24 09:17:46 -07:00
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
// Save the modified configuration
|
2024-10-24 09:17:46 -07:00
|
|
|
saveConfig(config)
|
|
|
|
rl.close()
|
2024-10-23 08:33:39 -07:00
|
|
|
})
|
2024-10-24 09:18:52 -07:00
|
|
|
} else if (answer.toLowerCase() === 'no') {
|
|
|
|
console.log('Athena\'s Shield not activated. Closing the CLI.')
|
2024-10-23 08:33:39 -07:00
|
|
|
config.athenaShieldActivated = false
|
2024-10-24 09:18:52 -07:00
|
|
|
config.menuVisibility = 'visible' // Reset to default value
|
2024-10-23 08:33:39 -07:00
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
// Save the modified configuration
|
2024-10-23 08:33:39 -07:00
|
|
|
saveConfig(config)
|
|
|
|
rl.close()
|
|
|
|
} else {
|
2024-10-24 09:18:52 -07:00
|
|
|
console.log('Invalid response.')
|
2024-10-23 08:33:39 -07:00
|
|
|
rl.close()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-10-24 09:18:52 -07:00
|
|
|
// Launch the CLI
|
2024-10-23 08:33:39 -07:00
|
|
|
startCLI()
|