mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 10:32:19 +08:00
feat: 减少重复截图 (#7945)
* feat: 减少重复截图 * feat: 截图间隔阈值改为 2min * style: 更新注释
This commit is contained in:
@@ -36,7 +36,17 @@ bool asst::ScreenshotTaskPlugin::verify(AsstMsg msg, const json::value& details)
|
||||
}
|
||||
|
||||
const std::string& task = details.get("details", "task", "");
|
||||
using namespace std::chrono_literals;
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
if (task == m_last_triggered_task && now - m_last_triggered_time < 2min) {
|
||||
// 2min 内同一个任务重复触发一般是卡在某个地方了,不再截图但更新时间
|
||||
Log.trace(__FUNCTION__, "| task", task, "triggered recently, skip");
|
||||
m_last_triggered_time = now;
|
||||
return false;
|
||||
}
|
||||
if (ranges::any_of(m_screenshot_tasks, [&task](std::string_view item) { return task.ends_with(item); })) {
|
||||
m_last_triggered_task = task;
|
||||
m_last_triggered_time = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,5 +20,7 @@ namespace asst
|
||||
static const constexpr std::string_view debug_config_name = "ScreenshotTaskPlugin-Config-Debug";
|
||||
|
||||
std::vector<std::string> m_screenshot_tasks;
|
||||
mutable std::string m_last_triggered_task; // 上次触发的任务这次不再触发
|
||||
mutable std::chrono::steady_clock::time_point m_last_triggered_time; // 触发的时间
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user