diff options
author | Lint Action <[email protected]> | 2021-07-31 08:17:46 +0000 |
---|---|---|
committer | Lint Action <[email protected]> | 2021-07-31 08:17:46 +0000 |
commit | 36d26d1dc61c36b4601aaf75e148060c5bcb98a7 (patch) | |
tree | 3b466c4b0db4b9e160c5390a1d1c7ddb0322660f /ATRI/plugins/rich/data_source.py | |
parent | 336eb9d9e98b0bee952c27a50820dbdb350bcc03 (diff) | |
download | ATRI-36d26d1dc61c36b4601aaf75e148060c5bcb98a7.tar.gz ATRI-36d26d1dc61c36b4601aaf75e148060c5bcb98a7.tar.bz2 ATRI-36d26d1dc61c36b4601aaf75e148060c5bcb98a7.zip |
:rotating_light: 自动进行代码格式化
Diffstat (limited to 'ATRI/plugins/rich/data_source.py')
-rw-r--r-- | ATRI/plugins/rich/data_source.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/ATRI/plugins/rich/data_source.py b/ATRI/plugins/rich/data_source.py index a59c922..96f77cf 100644 --- a/ATRI/plugins/rich/data_source.py +++ b/ATRI/plugins/rich/data_source.py @@ -25,10 +25,9 @@ __doc__ = """ class Rich(Service): - def __init__(self): Service.__init__(self, "小程序处理", __doc__, rule=is_in_service("小程序处理")) - + @staticmethod def _bv_dec(x) -> str: r = 0 @@ -36,7 +35,7 @@ class Rich(Service): r += tr[x[s[i]]] * 58 ** i result = "av" + str((r - add) ^ xor) return result - + @staticmethod def _bv_enc(x) -> str: x = (x ^ xor) + add @@ -44,7 +43,7 @@ class Rich(Service): for i in range(6): r[s[i]] = table[x // 58 ** i % 58] return "".join(r) - + @classmethod async def fk_bili(cls, text: str) -> tuple: """ @@ -53,7 +52,7 @@ class Rich(Service): """ msg = text.replace("\\", "") bv = False - + if "qqdocurl" not in msg: if "av" in msg: av = re.findall(r"(av\d+)", msg) @@ -71,7 +70,7 @@ class Rich(Service): if not bv_url: return "Get value (bv url) failed!", False bv_url = bv_url[3] - + try: res = await request.get(bv_url) except RequestError: @@ -80,7 +79,7 @@ class Rich(Service): if not bv: return "Get value (bv) failed!", False av = cls._bv_dec(bv[0]) - + if not bv: if "av" in msg: av = re.findall(r"(av\d+)", msg) @@ -89,7 +88,7 @@ class Rich(Service): av = av[0].replace("av", "") else: return "Not found av", False - + url = URL + av try: res = await request.get(url) @@ -97,11 +96,10 @@ class Rich(Service): return "Request failed!", False res_data = await res.json() data = res_data["data"] - + result = ( f"{data['bvid']} INFO:\n" f"Title: {data['title']}\n" f"Link: {data['short_link']}" ) return result, True -
\ No newline at end of file |