feat: 立即开始停止学习并整理学时历史与界面
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""账号自动学习任务的立即开始与停止。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from euniv.study_window import window_open
|
||||
|
||||
|
||||
class StudyControlError(ValueError):
|
||||
"""任务控制参数不符合要求。"""
|
||||
|
||||
|
||||
def start_now(account) -> None:
|
||||
account.study_paused = False
|
||||
account.study_ignore_window = True
|
||||
|
||||
|
||||
def stop_now(account) -> None:
|
||||
account.study_paused = True
|
||||
account.study_ignore_window = False
|
||||
|
||||
|
||||
def is_paused(account) -> bool:
|
||||
return bool(getattr(account, "study_paused", False))
|
||||
|
||||
|
||||
def ignores_window(account) -> bool:
|
||||
return bool(getattr(account, "study_ignore_window", False))
|
||||
|
||||
|
||||
def eligible(account) -> bool:
|
||||
if is_paused(account):
|
||||
return False
|
||||
if ignores_window(account):
|
||||
return True
|
||||
return window_open(account)
|
||||
|
||||
|
||||
def view_of(account) -> dict:
|
||||
paused = is_paused(account)
|
||||
ignore = ignores_window(account)
|
||||
opened = window_open(account)
|
||||
started = (not paused) and (ignore or opened)
|
||||
return {
|
||||
"paused": paused,
|
||||
"ignore_window": ignore,
|
||||
"window_open": opened,
|
||||
"started": started,
|
||||
}
|
||||
Reference in New Issue
Block a user