MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / doTargetTasks

Method doTargetTasks

wxapp/wb.js:331–369  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

329 }
330
331 async doTargetTasks() {
332 try {
333 const taskList = await this.getTaskList();
334 const tasks = taskList.filter((task) => TARGET_TASKS[task.indexNo]);
335 if (!tasks.length) {
336 $.log(`账号[${this.index}] 未找到目标任务`);
337 return;
338 }
339
340 for (const task of tasks) {
341 const taskName = task.taskName || TARGET_TASKS[task.indexNo];
342 if (String(task.status) === "2") {
343 $.log(`账号[${this.index}] ${taskName}: 已完成`);
344 continue;
345 }
346
347 if (String(task.status) === "0") {
348 const ok = await this.setTaskOk(task);
349 if (ok.code !== 200) {
350 $.log(`账号[${this.index}] ${taskName}: 标记完成失败 ${ok.message || ok.code}`);
351 continue;
352 }
353 }
354
355 const complete = await this.completeTask(task);
356 if (complete.code === 200) {
357 $.log(`账号[${this.index}] ${taskName}: 领取成功 +${task.awardsValue || "未知"}能量`);
358 } else if (complete.code === 21210108) {
359 $.log(`账号[${this.index}] ${taskName}: 奖励已领取`);
360 } else {
361 $.log(`账号[${this.index}] ${taskName}: 领取失败 ${complete.message || complete.code}`);
362 }
363 }
364 } catch (e) {
365 const message = e.message || e;
366 $.log(`账号[${this.index}] 任务中心失败: ${message}`);
367 if (isTokenError(message)) this.removeCachedToken();
368 }
369 }
370}
371
372!(async () => {

Callers 1

runMethod · 0.95

Calls 6

getTaskListMethod · 0.95
setTaskOkMethod · 0.95
completeTaskMethod · 0.95
removeCachedTokenMethod · 0.95
isTokenErrorFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected