mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
🎨 Improve get_args
function in Abyss Plugin
This commit is contained in:
parent
8ecc9f97a7
commit
feeb9d0152
@ -29,15 +29,20 @@ except ImportError:
|
|||||||
|
|
||||||
TZ = timezone("Asia/Shanghai")
|
TZ = timezone("Asia/Shanghai")
|
||||||
|
|
||||||
|
get_args_pattern = re.compile(r"\d+")
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def get_args(text: str) -> Tuple[int, bool, bool]:
|
def get_args(text: str) -> Tuple[int, bool, bool]:
|
||||||
total = "all" in text or "总览" in text
|
total = "all" in text or "总览" in text
|
||||||
prev = "pre" 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
|
return floor, total, prev
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user