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

Method doDailyTasks

wxapp/yichengtong.js:356–383  ·  view source on GitHub ↗
(taskHome = null)

Source from the content-addressed store, hash-verified

354 }
355
356 async doDailyTasks(taskHome = null) {
357 const data = taskHome || (await this.queryTaskHome());
358 if (!data) return;
359 const todayTask = Array.isArray(data.todayTask) ? data.todayTask : [];
360 const runnable = todayTask.filter((task) => {
361 const total = Number(task.num || 1);
362 const done = Number(task.completeCount || 0);
363 return done < total && AUTO_TASK_TYPES.has(Number(task.functionType));
364 });
365 if (!runnable.length) {
366 $.log(`账号[${this.index}] 每日任务: 暂无可自动执行任务`);
367 return;
368 }
369
370 for (const task of runnable) {
371 const total = Number(task.num || 1);
372 let done = Number(task.completeCount || 0);
373 const waitSeconds = Math.max(0, Number(task.second || 0));
374 while (done < total) {
375 $.log(`账号[${this.index}] 执行每日任务: ${taskName(task)} ${done + 1}/${total}`);
376 if (waitSeconds > 0) await $.wait(waitSeconds * 1000 + 500, waitSeconds * 1000 + 1800);
377 const success = await this.submitTask(task);
378 if (!success) break;
379 done += 1;
380 await $.wait(800, 1500);
381 }
382 }
383 }
384
385 async run() {
386 await this.ensureLogin();

Callers 1

runMethod · 0.95

Calls 5

queryTaskHomeMethod · 0.95
submitTaskMethod · 0.95
taskNameFunction · 0.85
logMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected