Files
bettergi-scripts-list/repo/js/AutoCommission/lib/steps/auto-task.js
DarkFlameMaster 10d06c3487 同步AutoCommission更新 (#2746)
Co-authored-by: DarkFlameMaster <actions@github.com>
2026-01-20 14:21:48 +08:00

68 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 自动任务步骤处理器
(function() {
StepProcessorLoader.register("自动任务", async function(step, context) {
try {
var action = step.data && step.data.action;
var taskType = (step.data && step.data.taskType) || "default";
var config = (step.data && step.data.config) || {};
if (!action) {
log.error("自动任务参数不完整,需要 action 参数");
return false;
}
log.info("执行自动任务操作: {action}", action);
switch (action) {
case "enable":
// 启用自动任务
if (!taskType) {
log.error("启用自动任务需要指定 taskType");
return false;
}
// 如果taskType是AutoSkip只使用无配置的构造函数
// 然后再根据config判断调用AutoPick时是否传参
if (taskType === "AutoSkip") {
log.info("启用自动剧情", taskType);
dispatcher.addTimer(new RealtimeTimer(taskType));
} else if (config && typeof config === "object") {
log.info("启用自动任务: {type},配置: {config}", taskType, JSON.stringify(config));
dispatcher.addTimer(new RealtimeTimer(taskType, config));
} else {
log.info("启用自动任务: {type}", taskType);
dispatcher.addTimer(new RealtimeTimer(taskType));
}
break;
case "disable":
// 取消所有自动任务
log.info("取消所有自动任务");
dispatcher.ClearAllTriggers();
break;
default:
log.error("未知的自动任务操作: {action}", action);
return false;
}
return true;
} catch (error) {
log.error("处理自动任务步骤时出错: {error}", error.message);
return false;
}
});
})();
/*
JSON使用示例:
{
"type": "自动任务",
"data": {
"action": "enable", // 必需: "enable"启用任务, "disable"禁用任务
"taskType": "default", // 启用时必需: 任务类型
"config": {} // 可选: 任务配置
},
"note": "启用/禁用自动任务"
}
*/