-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Nyakku Shigure <[email protected]>
- Loading branch information
Showing
10 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from __future__ import annotations | ||
|
||
import datetime | ||
import re | ||
|
||
from yutto.utils.console.logger import Logger | ||
|
||
|
||
class Filter: | ||
batch_filter_start_time: datetime.datetime = datetime.datetime.min | ||
batch_filter_end_time: datetime.datetime = datetime.datetime.max | ||
|
||
@staticmethod | ||
def set_timer(key: str, user_input: str): | ||
"""设置过滤器的时间""" | ||
timer: datetime.datetime | None = None | ||
if re.match(r"^\d{4}-\d{2}-\d{2}$", user_input): | ||
timer = datetime.datetime.strptime(user_input, "%Y-%m-%d") | ||
elif re.match(r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$", user_input): | ||
timer = datetime.datetime.strptime(user_input, "%Y-%m-%d %H:%M:%S") | ||
else: | ||
Logger.error(f"稿件过滤参数: {user_input} 看不懂呢┭┮﹏┭┮,不会生效哦") | ||
return | ||
setattr(Filter, key, timer) | ||
|
||
@staticmethod | ||
def verify_timer(timestamp: int) -> bool: | ||
return Filter.batch_filter_start_time.timestamp() <= timestamp < Filter.batch_filter_end_time.timestamp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters