MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / runAccount

Function runAccount

wxapp/qqpcmgr.js:280–304  ·  view source on GitHub ↗
(account, index)

Source from the content-addressed store, hash-verified

278}
279
280async function runAccount(account, index) {
281 const guid = process.env[`${CK_NAME}_guid_${index}`] || CLIENT_GUID;
282 $.log(`\n[账号${index}] 开始处理 ${account || "authCode"}`);
283 const authCode = await getAuthCode(account);
284 $.log(`[账号${index}] 获取 authCode 成功 ${String(authCode).slice(0, 8)}***`);
285
286 const payload = await loginByCode(authCode, guid);
287 const profile = normalizeProfile(payload, guid);
288 if (!profile.loginKey || !profile.openid) throw new Error("登录资料缺少 loginKey/openid");
289
290 const cookie = buildCookie(profile);
291 $.log(`[账号${index}] 登录资料: account=${profile.account} openid=${profile.openid} nickname=${profile.nickname}`);
292 $.log(`[账号${index}] Cookie: ${cookie}`);
293
294 const auth = await createAuth(profile, cookie);
295 $.log(`[账号${index}] auth/create HTTP ${auth.status}`);
296 $.log(`[账号${index}] auth/create 返回: ${JSON.stringify(auth.data)}`);
297
298 const sessionKey = auth.data?.data?.userInfo?.sessionKey || auth.data?.data?.sessionKey || auth.data?.sessionKey;
299 if (!sessionKey) throw new Error(`auth/create 未返回 sessionKey: ${JSON.stringify(auth.data)}`);
300
301 const lottery = await doLottery(sessionKey, cookie);
302 $.log(`[账号${index}] doLottery(${LOTTERY_ID}) HTTP ${lottery.status}`);
303 $.log(`[账号${index}] doLottery 返回: ${JSON.stringify(lottery.data)}`);
304}
305
306(async () => {
307 const accounts = process.env.qqpcmgr_authCode ? [""] : splitAccounts(process.env[CK_NAME] || "");

Callers 1

qqpcmgr.jsFile · 0.70

Calls 7

getAuthCodeFunction · 0.85
normalizeProfileFunction · 0.85
buildCookieFunction · 0.85
createAuthFunction · 0.85
doLotteryFunction · 0.85
loginByCodeFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected