This commit is contained in:
2024
2025-01-14 13:06:24 +08:00
parent a069399a69
commit ba4b018953
2 changed files with 24 additions and 9 deletions

9
jx_ttlhb.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -2125,22 +2125,28 @@ function GetnickName2() {
} }
const got = require('got'); const got = require('got');
require('dotenv').config(); require('dotenv').config();
let exists = fs.existsSync('/ql/data/config/auth.json'); let Fileexists280 = fs.existsSync('/ql/data/db/keyv.sqlite');
let Fileexists_ = fs.existsSync('/ql/data/config/auth.json');
let authFile = ""; let authFile = "";
if (exists) if (Fileexists280)
authFile = "/ql/data/db/keyv.sqlite"
else if (Fileexists_)
authFile = "/ql/data/config/auth.json" authFile = "/ql/data/config/auth.json"
else else
authFile = "/ql/config/auth.json" authFile = "/ql/config/auth.json"
const api = got.extend({ const api = got.extend({
prefixUrl: 'http://127.0.0.1:5600', prefixUrl: 'http://127.0.0.1:5600',
retry: { limit: 0 }, retry: { limit: 0 },
}); });
async function getToken() { async function getToken() {
const authConfig = JSON.parse(fs.readFileSync(authFile)); const authConfig = await fs.readFileSync(authFile);
return authConfig.token; // console.log(authConfig.toString().match(/"token":"(.*?)",/)[1])
return authConfig.toString().match(/"token":"(.*?)",/)[1];
} }
// getToken()
async function getEnvs(){ async function getEnvs(){
const token = await getToken(); const token = await getToken();