MCPcopy Create free account
hub / github.com/chavyleung/scripts / claimGift

Function claimGift

zsfc/zsfc.js:534–583  ·  view source on GitHub ↗

* @description 掌飞签到相关函数,领取礼物函数 * @param {string} giftId 礼物 ID * @param {string} giftName 礼物名称

(giftId, giftName)

Source from the content-addressed store, hash-verified

532 * @param {string} giftName 礼物名称
533 */
534async function claimGift(giftId, giftName) {
535 // 构建请求体
536 const options = {
537 url: `https://comm.ams.game.qq.com/ams/ame/amesvr?${$.queryStr({
538 "sServiceType": "speed", // params部分必须加上 sServiceType=speed 参数
539 "iActivityId": $.read(`zsfc_iActivityId`)
540 })}`,
541 headers: {
542 "Cookie": $.cookieStr({
543 "access_token": $.read(`zsfc_accessToken`),
544 "acctype": "qc",
545 "appid": "1105330667",
546 "openid": $.read(`zsfc_openid`)
547 })
548 },
549 body: $.queryStr({
550 "iActivityId": $.read(`zsfc_iActivityId`),
551 "iFlowId": giftId,
552 "g_tk": "1842395457"
553 })
554 };
555
556 // 返回一个 Promise 对象,用于异步操作
557 return new Promise(resolve => {
558 // 发送 POST 请求,获取领取结果
559 $.post(options, (err, resp, data) => {
560 if (data) {
561 let body = $.toObj(data.replace(/\r|\n/ig, ``));
562 if (body.msg.includes(`已经`)) {
563 $.log(`✅ ${giftName}: 已经领取`);
564 // $.checkInMsg += `, ${giftName}`;
565 } else if (body.msg.includes(`不满足`)) {
566 $.log(`⭕ ${giftName}: ${body.flowRet.sMsg}`);
567 } else {
568 const sPackageName = body.modRet.sPackageName.replace(/[,,]/g, ", ");
569 $.log(`✅ ${giftName}: ${sPackageName}`);
570 if ($.checkInMsg) {
571 $.checkInMsg += `,${sPackageName}`;
572 } else {
573 $.checkInMsg = `领取结果: 获得${sPackageName}`
574 }
575 }
576 } else {
577 $.log(`❌ ${giftName}: 发生错误`);
578 $.log($.toStr(err));
579 }
580 resolve();
581 });
582 });
583}
584
585/**
586 * @description 掌飞签到相关函数,浏览背包

Callers 1

zsfc.jsFile · 0.85

Calls 5

queryStrMethod · 0.45
postMethod · 0.45
toObjMethod · 0.45
logMethod · 0.45
toStrMethod · 0.45

Tested by

no test coverage detected