MCPcopy Create free account
hub / github.com/Semporia/Scripts / getTask

Function getTask

activity/jd_festival.js:208–248  ·  view source on GitHub ↗
(share = false)

Source from the content-addressed store, hash-verified

206}
207
208function getTask(share = false) {
209 return new Promise(resolve => {
210 $.get(taskUrl('task/queryGeneralTasks'), async (err, resp, data) => {
211 try {
212 if (err) {
213 console.log(`${JSON.stringify(err)}`)
214 console.log(`${$.name} API请求失败,请检查网路重试`)
215 } else {
216 if (safeGet(data)) {
217 data = JSON.parse(data);
218 if (data.code === 200) {
219 const {shareTask, generalTasks} = data.data
220 if (share)
221 console.log(`您的好友助力码为:${shareTask.shareId},当前助力进度:${shareTask.needSupportNum - shareTask.remainSupportNum}/${shareTask.needSupportNum}`)
222 else
223 for (let vo of generalTasks) {
224 console.log(`任务${vo.id}完成进度:${vo.finish}/${vo.total}`)
225 if (vo.finish < vo.total) {
226 await doTask(vo.type)
227 await $.wait(10 * 1000)
228 }
229 if (vo.status === "3") {
230 console.log(`任务已完成,去领奖`)
231 await doReceive(vo.type)
232 } else if (vo.status === "4") {
233 console.log(`任务已领奖`)
234 }
235 }
236 } else {
237 console.log(`任务获取失败`)
238 }
239 }
240 }
241 } catch (e) {
242 $.logErr(e, resp)
243 } finally {
244 resolve();
245 }
246 })
247 })
248}
249
250function getExtTask() {
251 return new Promise(resolve => {

Callers 1

festivalFunction · 0.70

Calls 8

doReceiveFunction · 0.85
taskUrlFunction · 0.70
safeGetFunction · 0.70
doTaskFunction · 0.70
getMethod · 0.45
logMethod · 0.45
waitMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected