diff options
Diffstat (limited to 'ATRI/plugins/rich')
-rw-r--r-- | ATRI/plugins/rich/__init__.py | 31 | ||||
-rw-r--r-- | ATRI/plugins/rich/data_source.py | 10 |
2 files changed, 20 insertions, 21 deletions
diff --git a/ATRI/plugins/rich/__init__.py b/ATRI/plugins/rich/__init__.py index 14b9534..ce5d422 100644 --- a/ATRI/plugins/rich/__init__.py +++ b/ATRI/plugins/rich/__init__.py @@ -8,7 +8,7 @@ from nonebot.adapters.cqhttp.message import MessageSegment from ATRI.service import Service as sv from ATRI.utils.request import get_bytes -from ATRI.utils.list import count_list, del_list_aim +from ATRI.utils.limit import is_too_exciting from .data_source import dec @@ -16,23 +16,22 @@ from .data_source import dec temp_list = [] img_url = [ "https://cdn.jsdelivr.net/gh/Kyomotoi/CDN@master/project/ATRI/fkrich.png", - "https://cdn.jsdelivr.net/gh/Kyomotoi/CDN@master/project/ATRI/xixi.jpg", + "https://cdn.jsdelivr.net/gh/Kyomotoi/CDN@master/project/ATRI/xixi.jpg" ] bilibili_rich = sv.on_message() - @bilibili_rich.handle() async def _bilibili_rich(bot: Bot, event: MessageEvent) -> None: global temp_list try: msg = str(event.raw_message).replace("\\", "") bv = False - + if "qqdocurl" not in msg: if "av" in msg: - av = re.findall(r"(av\d+)", msg)[0].replace("av", "") + av = re.findall(r"(av\d+)", msg)[0].replace('av', '') else: bv = re.findall(r"(BV\w+)", msg) av = str(dec(bv[0])) @@ -44,29 +43,29 @@ async def _bilibili_rich(bot: Bot, event: MessageEvent) -> None: async with session.get(url=bv_url) as r: bv = re.findall(r"(BV\w+)", str(r.url)) av = dec(bv[0]) - + if not bv: if "av" in msg: - av = re.findall(r"(av\d+)", msg)[0].replace("av", "") + av = re.findall(r"(av\d+)", msg)[0].replace('av', '') else: return - - if count_list(temp_list, av) == 4: - await bot.send(event, "你是怕别人看不到么发这么多次?") - temp_list = del_list_aim(temp_list, av) + + user = event.user_id + check = is_too_exciting(user, 1, 10) + if not check: return - - temp_list.append(av) - + URL = f"https://api.kyomotoi.moe/api/bilibili/v2/?aid={av}" - data = json.loads(await get_bytes(URL))["data"] + data = json.loads(await get_bytes(URL))['data'] repo = ( f"{data['bvid']} INFO:\n" f"Title: {data['title']}\n" f"Link: {data['short_link']}\n" "にまねげぴのTencent rich!" ) - await bot.send(event, MessageSegment.image(file=choice(img_url))) + await bot.send( + event, + MessageSegment.image(file=choice(img_url))) await bilibili_rich.finish(repo) except BaseException: return diff --git a/ATRI/plugins/rich/data_source.py b/ATRI/plugins/rich/data_source.py index 59474ff..32ac219 100644 --- a/ATRI/plugins/rich/data_source.py +++ b/ATRI/plugins/rich/data_source.py @@ -1,4 +1,4 @@ -table = "fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF" +table = 'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF' tr = {} for i in range(58): tr[table[i]] = i @@ -10,13 +10,13 @@ add = 8728348608 def dec(x) -> int: r = 0 for i in range(6): - r += tr[x[s[i]]] * 58 ** i + r += tr[x[s[i]]] * 58**i return (r - add) ^ xor def enc(x) -> str: x = (x ^ xor) + add - r = list("BV1 4 1 7 ") + r = list('BV1 4 1 7 ') for i in range(6): - r[s[i]] = table[x // 58 ** i % 58] - return "".join(r) + r[s[i]] = table[x // 58**i % 58] + return ''.join(r) |