feat: add hashed profiles functionality for bot usernames
This commit is contained in:
parent
d26de80759
commit
77af2a3912
46
hashed_profiles.js
Normal file
46
hashed_profiles.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
const crypto = require("crypto");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
// Add all bot usernames here.
|
||||||
|
const USERNAMES = [
|
||||||
|
"ZareMate",
|
||||||
|
"Tomek",
|
||||||
|
"Cytrus",
|
||||||
|
"Qawe",
|
||||||
|
"Bot",
|
||||||
|
"Skybloczek",
|
||||||
|
"Bronkol",
|
||||||
|
];
|
||||||
|
const homedir = require("os").homedir();
|
||||||
|
const HASHED_PROFILES_FOLDER = `${homedir}/.minecraft/nmp-cache`;
|
||||||
|
|
||||||
|
function createHash(input) {
|
||||||
|
return crypto
|
||||||
|
.createHash("sha1")
|
||||||
|
.update(input ?? "", "binary")
|
||||||
|
.digest("hex")
|
||||||
|
.substr(0, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkIfHashedPresent(username) {
|
||||||
|
const hash = createHash(username);
|
||||||
|
|
||||||
|
const xblPath = `${HASHED_PROFILES_FOLDER}/${hash}_xbl-cache.json`;
|
||||||
|
const mcaPath = `${HASHED_PROFILES_FOLDER}/${hash}_mca-cache.json`;
|
||||||
|
const livePath = `${HASHED_PROFILES_FOLDER}/${hash}_live-cache.json`;
|
||||||
|
|
||||||
|
const exists =
|
||||||
|
fs.existsSync(xblPath) || fs.existsSync(mcaPath) || fs.existsSync(livePath);
|
||||||
|
return { exists, hash };
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkAllHashedProfiles() {
|
||||||
|
const results = {};
|
||||||
|
for (const username of USERNAMES) {
|
||||||
|
const { exists, hash } = checkIfHashedPresent(username);
|
||||||
|
results[username] = { hash, exists };
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(checkAllHashedProfiles());
|
||||||
Loading…
x
Reference in New Issue
Block a user