mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
fix: 循环引用
This commit is contained in:
parent
a8919c008e
commit
9273502008
@ -16,4 +16,5 @@ set COOKIE=
|
||||
set NUMBER=1
|
||||
set CLEAR=true
|
||||
set SCKEY=
|
||||
set PUSH_PLUS_TOKEN=
|
||||
set PUSH_PLUS_TOKEN=
|
||||
set LOCALLAUNCH=true
|
||||
@ -2,7 +2,6 @@ const { createReadStream, createWriteStream } = require('fs')
|
||||
const unzip = require('unzipper');
|
||||
const { strToJson } = require("./Base")
|
||||
const { HttpRequest } = require("./HttpRequest")
|
||||
const GlobalVar = require('./GlobalVar.json')
|
||||
|
||||
const { GITHUB_REPOSITORY } = process.env;
|
||||
|
||||
@ -44,19 +43,20 @@ const GihubAPI = {
|
||||
});
|
||||
},
|
||||
/**
|
||||
*
|
||||
* 下载构件
|
||||
* @param {string} PAT
|
||||
* @param {number} id
|
||||
* @param {number} size
|
||||
* @returns {Promise<boolean>} success: true
|
||||
*/
|
||||
downloadArtifacts: (id, size) => {
|
||||
downloadArtifacts: (PAT, id, size) => {
|
||||
return new Promise((resolve) => {
|
||||
HttpRequest({
|
||||
method: 'GET',
|
||||
url: `https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/artifacts/${id}/zip`,
|
||||
headers: {
|
||||
accept: 'application/vnd.github.v3+json',
|
||||
Authorization: `token ${GlobalVar.PAT}`
|
||||
Authorization: `token ${PAT}`
|
||||
},
|
||||
config: {
|
||||
redirect: true,
|
||||
|
||||
@ -6,12 +6,12 @@ const MyStorage = {
|
||||
/**
|
||||
* 初始化dyid.txt
|
||||
*/
|
||||
init: () => {
|
||||
init: (PAT) => {
|
||||
return new Promise((resolve) => {
|
||||
GihubAPI.listArtifacts().then(async artifact => {
|
||||
const { id, size_in_bytes } = artifact;
|
||||
if (size_in_bytes) {
|
||||
GihubAPI.downloadArtifacts(id, size_in_bytes).then(async status => {
|
||||
if (PAT && size_in_bytes) {
|
||||
GihubAPI.downloadArtifacts(PAT, id, size_in_bytes).then(async status => {
|
||||
if (status) {
|
||||
console.log('存储初始化成功');
|
||||
} else {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const Script = require("./Script");
|
||||
const { getRemoteConfig } = require("./Base");
|
||||
const MyStorage = require("./MyStorage");
|
||||
const Base = require("./Base");
|
||||
|
||||
@ -28,7 +27,6 @@ async function setVariable(cookie, PAT = '', SCKEY = '', PUSH_PLUS_TOKEN = '') {
|
||||
const key = ['DedeUserID','bili_jct']
|
||||
GlobalVar.cookie = cookie;
|
||||
GlobalVar.SCKEY = SCKEY;
|
||||
GlobalVar.PAT = PAT;
|
||||
GlobalVar.PUSH_PLUS_TOKEN = PUSH_PLUS_TOKEN;
|
||||
cookie.split(/\s*;\s*/).forEach(item=>{
|
||||
const _item = item.split('=');
|
||||
@ -36,9 +34,9 @@ async function setVariable(cookie, PAT = '', SCKEY = '', PUSH_PLUS_TOKEN = '') {
|
||||
})
|
||||
GlobalVar.csrf = GlobalVar.bili_jct;
|
||||
GlobalVar.myUID = GlobalVar.DedeUserID;
|
||||
GlobalVar.remoteconfig = await getRemoteConfig();
|
||||
GlobalVar.remoteconfig = await Base.getRemoteConfig();
|
||||
await Base.ifNotExistCreateFile('GlobalVar.json',JSON.stringify(GlobalVar));
|
||||
await MyStorage.init()
|
||||
await MyStorage.init(PAT)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
3
main.js
3
main.js
@ -1,9 +1,10 @@
|
||||
const { setVariable } = require("./lib/setVariable");
|
||||
|
||||
const { NUMBER, CLEAR, COOKIE, PAT, SCKEY, PUSH_PLUS_TOKEN } = process.env;
|
||||
const { NUMBER, CLEAR, COOKIE, PAT, SCKEY, PUSH_PLUS_TOKEN, LOCALLAUNCH } = process.env;
|
||||
|
||||
((async () => {
|
||||
if (typeof COOKIE === 'string' && COOKIE.length > 10) {
|
||||
if (!LOCALLAUNCH && !PAT) { console.log('请查看README文件, 填入相应的PAT'); return; }
|
||||
await setVariable(COOKIE, PAT, SCKEY, PUSH_PLUS_TOKEN);
|
||||
const { start, isMe, checkCookie } = require("./lib/lottery-in-nodejs");
|
||||
const { clear } = require("./lib/clear");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user