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

Method tryLotteryOnce

wxapp/wps.js:538–577  ·  view source on GitHub ↗
(index)

Source from the content-addressed store, hash-verified

536 }
537
538 async tryLotteryOnce(index) {
539 const actCsrf = randomHex(16);
540 const body = {
541 component_uniq_number: {
542 activity_number: LOTTERY_ACTIVITY,
543 page_number: LOTTERY_PAGE_NO,
544 component_number: LOTTERY_COMPONENT_NO,
545 component_node_id: LOTTERY_COMPONENT_NODE_ID,
546 filter_params: {},
547 },
548 component_type: 45,
549 component_action: "lottery_v2.exec",
550 lottery_v2: {
551 session_id: 1,
552 },
553 };
554 const cookies = { ...this.cookies, act_csrf_token: actCsrf };
555 const res = await wpsRequest("POST", COMPONENT_ACTION, {
556 data: body,
557 cookies,
558 secret: this.secret,
559 headers: {
560 "Content-Type": "application/json",
561 "X-Act-Csrf-Token": actCsrf,
562 Referer: LOTTERY_PAGE,
563 },
564 }).catch((e) => ({ data: { result: "error", msg: e.message || String(e) }, cookies: this.cookies }));
565 this.cookies = mergeSetCookie([], { ...this.cookies, ...res.cookies });
566 this.saveCache();
567
568 const result = res.data;
569 if (result?.result === "ok" && result.data?.lottery_v2?.success) {
570 const reward = result.data.lottery_v2;
571 $.log(`账号[${this.index}] 抽奖[${index}]成功: ${reward.reward_name || reward.reward_type || JSON.stringify(reward).slice(0, 120)}`);
572 return true;
573 }
574 const detail = result?.data?.lottery_v2?.error_code ? `错误码${result.data.lottery_v2.error_code}` : result?.msg || JSON.stringify(result);
575 $.log(`账号[${this.index}] 抽奖[${index}]失败: ${detail}`);
576 return false;
577 }
578
579 async lottery() {
580 const count = await this.lotteryTimes();

Callers 1

lotteryMethod · 0.95

Calls 5

saveCacheMethod · 0.95
randomHexFunction · 0.85
wpsRequestFunction · 0.85
mergeSetCookieFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected