🎨 Improve get_args function in Abyss Plugin

This commit is contained in:
洛水居室 2023-10-20 12:30:24 +08:00
parent 8ecc9f97a7
commit feeb9d0152
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -29,15 +29,20 @@ except ImportError:
TZ = timezone("Asia/Shanghai")
get_args_pattern = re.compile(r"\d+")
@lru_cache
def get_args(text: str) -> Tuple[int, bool, bool]:
total = "all" in text or "总览" in text
prev = "pre" in text or "上期" in text
try:
floor = 0 if total else int(re.search(r"\d+", text).group(0))
except (ValueError, IndexError, AttributeError):
floor = 0
floor = 0
if not total:
m = get_args_pattern.search(text)
if m is not None:
floor = int(m.group(0))
return floor, total, prev