diff --git a/index.js b/index.js index 55aacc1c..e2d27b11 100644 --- a/index.js +++ b/index.js @@ -114,7 +114,7 @@ function sendUserNotify({ status, message, account, userInfo }) { function sendGlobalNotify(tasks) { const message = tasks.map((t) => `账号 ${t.user}:\n${t.data}`).join('\n\n') const errorTasks = tasks.filter((t) => t.status == 'error') - const allFailed = tasks.length > 1 && errorTasks.length === tasks.length + const allFailed = tasks.length && errorTasks.length === tasks.length const title = `${NOTIFY_TITLE}${ allFailed ? '😥' diff --git a/src/coupons/DCwpqO.js b/src/coupons/DCwpqO.js index 9512d82a..e799cd45 100644 --- a/src/coupons/DCwpqO.js +++ b/src/coupons/DCwpqO.js @@ -163,7 +163,7 @@ async function grabCoupon(cookie) { } export default { - grabCoupon: grabCoupon, - getActUrl: getActUrl + grabCoupon, + getActUrl } export { getParams } diff --git a/src/coupons/index.js b/src/coupons/index.js index 431324b4..ba04cf01 100644 --- a/src/coupons/index.js +++ b/src/coupons/index.js @@ -2,7 +2,6 @@ import fetch from '../fetch.js' import ShadowGuard from '../shadow/index.js' import { createMTCookie, getUserInfo } from '../user.js' import gundamGrab from './gundamGrab.js' -import DCwpqO from './DCwpqO.js' import { couponId, ECODE } from './const.js' async function runTask(cookie, guard) { @@ -20,24 +19,15 @@ async function runTask(cookie, guard) { grabResult.push(...mainResult) - try { - const qualityShopResult = await gundamGrab.grabCoupon( - cookie, - couponId.shop.gid, - guard - ) - - grabResult.push(...qualityShopResult) - } catch { - // 仅对某些用户群体生效 - } - // try { - // const DCwpqOResult = await DCwpqO.grabCoupon(cookie) - - // grabResult.push(...DCwpqOResult) - // } catch (e) { - // console.log('eeee', e) + // const qualityShopResult = await gundamGrab.grabCoupon( + // cookie, + // couponId.shop.gid, + // guard + // ) + + // grabResult.push(...qualityShopResult) + // } catch { // // 仅对某些用户群体生效 // } diff --git a/src/payload.js b/src/payload.js index 6503df32..b15c3a3b 100644 --- a/src/payload.js +++ b/src/payload.js @@ -1,16 +1,10 @@ import fetch from './fetch.js' import { getRenderList } from './template.js' -function parseInstanceID(moduleId) { - const regFloat = /(\d+\.\d+)/ - - return moduleId.match(regFloat)?.[1] ?? '' -} - function matchMoudleData(id, jsText) { const endField = 'isStopTJCoupon' const reg = new RegExp( - `gdc-fx-new-netunion-red-envelope-${id}.+?(?=${endField})` + `gdc-fx-v2-netunion-red-envelope-${id}.+?(?=${endField})` ) const res = jsText.match(reg) diff --git a/src/template.js b/src/template.js index d1924dbf..f6e98fb4 100644 --- a/src/template.js +++ b/src/template.js @@ -30,7 +30,7 @@ async function getTemplateData(cookie, gundamId) { } // 通过接口获取真实的渲染列表 -async function getRenderList(gdId, guard) { +async function getRenderList(gdNumId, guard) { let data try { @@ -40,7 +40,7 @@ async function getRenderList(gdId, guard) { params: { el_biz: 'waimai', el_page: 'gundam.loader', - gdId: gdId, + gdId: gdNumId, tenant: 'gundam' }, guard @@ -52,7 +52,11 @@ async function getRenderList(gdId, guard) { throw new Error('renderinfo 接口调用失败:' + e.message) } - return Object.keys(data).filter((k) => data[k].render) + const renderList = Object.entries(data) + .filter(([_, v]) => v.render) + .map(([k]) => k) + + return renderList } export { getTemplateData, getRenderList } diff --git a/test/payload.js b/test/payload.js index 01c5a260..8c8747b5 100644 --- a/test/payload.js +++ b/test/payload.js @@ -20,7 +20,7 @@ test('Test getTemplateData', async () => { }) test('Test getRenderList', async () => { - const renderList = await getRenderList(couponId.main.gid, guard) + const renderList = await getRenderList(531693, guard) return expect(renderList).toEqual(expect.any(Array)) })