1
0
mirror of https://github.com/6dylan6/jdpro.git synced 2025-07-19 19:04:21 +08:00
This commit is contained in:
2024
2025-03-10 11:48:06 +08:00
parent 50b5b4f6bd
commit 8cbc17d31e

View File

@@ -2125,21 +2125,28 @@ function GetnickName2() {
} }
const got = require('got'); const got = require('got');
require('dotenv').config(); require('dotenv').config();
let Fileexists280 = fs.existsSync('/ql/data/db/keyv.sqlite'); const tokenFileList = ['/ql/data/db/keyv.sqlite', '/ql/data/config/auth.json', '/ql/config/auth.json'];
let Fileexists_ = fs.existsSync('/ql/data/config/auth.json'); let authFile = getLatestFile(tokenFileList);
let authFile = "";
if (Fileexists280&&process.env.QL_BRANCH.slice(1,5)>=2.18)
authFile = "/ql/data/db/keyv.sqlite"
else if (Fileexists_)
authFile = "/ql/data/config/auth.json"
else
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 },
}); });
function getLatestFile(files) {
let latestFile = null;
let latestMtime = 0;
for (const file of files) {
try {
const stats = fs.statSync(file);
const mtime = stats.mtimeMs;
if (mtime > latestMtime) {
latestMtime = mtime;
latestFile = file;
}
} catch (e) {
}
}
return latestFile;
}
async function getToken() { async function getToken() {
const authConfig = await fs.readFileSync(authFile); const authConfig = await fs.readFileSync(authFile);