diff options
Diffstat (limited to 'ATRI/plugins/plugin_rich')
-rw-r--r-- | ATRI/plugins/plugin_rich/__init__.py | 141 | ||||
-rw-r--r-- | ATRI/plugins/plugin_rich/data_source.py | 34 |
2 files changed, 0 insertions, 175 deletions
diff --git a/ATRI/plugins/plugin_rich/__init__.py b/ATRI/plugins/plugin_rich/__init__.py deleted file mode 100644 index 6d2dec8..0000000 --- a/ATRI/plugins/plugin_rich/__init__.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : __init__.py -@Time : 2020/10/11 14:40:34 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import re -import json -import requests - -from nonebot.log import logger -from nonebot.typing import Bot, Event -from nonebot.plugin import on_message - -from ATRI.utils.utils_times import countX -from ATRI.utils.utils_rule import check_banlist -from ATRI.utils.utils_request import request_get -from .data_source import dec - -BILI_REPORT_FORMAT = """[{aid}] Info: -Title: {title} -bid: {bid} -Viev: {view} Like: {like} -Coin: {coin} Share: {share} -Link: -{aid_link} -{bid_link}""" - -bilibiliRich = on_message(rule=check_banlist()) -b_list = [] - - -async def _(bot: Bot, event: Event, state: dict) -> None: - global b_list - user = event.user_id - msg = str(event.message) - - # 防刷屏机制:回复次数达到五次自动忽略下一次 - if countX(b_list, user) == 5: - return - - if "qqdocurl" not in msg: - try: - bv = re.findall(r"(BV\w+)", msg) - except: - return - else: - bvURL = re.findall(r"(........b23...\S+\=)", msg) - - try: - r = requests.get(bvURL[0], stream=True, allow_redirects=True) - except: - logger.waring("Get BV ERROR. (Request ERROR)") - return - - bv = re.findall(r"(BV\w+)", r.url) - - if bv: - aid = str(dec(bv[0])) - ad = 'av' + aid - URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}' - - try: - res = request_get(URL) - except: - logger.waring("Request ERROR") - return - - data = json.loads(res) - msg = BILI_REPORT_FORMAT.format(title=data["data"]["title"], - view=data["data"]["stat"]["view"], - coin=data["data"]["stat"]["coin"], - share=data["data"]["stat"]["share"], - like=data["data"]["stat"]["like"], - bid=data["data"]["bvid"], - bid_link=data["data"]["short_link"], - aid=ad, - aid_link=f'https://b23.tv/{ad}') - - b_list.append(user) - await bilibiliRich.finish(msg) - - else: - return - - -CLOUDMUSIC_REPORT_FORMAT = """Status: {status} -Song id: {id} -Br: {br} -Download: {url} -MD5: {md5}""" - -cloudmusicRich = on_message(rule=check_banlist()) -c_list = [] - - -async def _(bot: Bot, event: Event, state: dict) -> None: - global c_list - user = event.user_id - msg = str(event.message) - - # 防刷屏机制:回复次数达到五次自动忽略下一次 - if countX(b_list, user) == 5: - return - - if "music.163.com" in msg: - music_id = re.findall(r"song\S+\/|id=\S+\&", msg) - - if music_id: - music_id = str(music_id[0]) - music_id = re.findall(r"-?[1-9]\d*", music_id) - URL = f'https://api.imjad.cn/cloudmusic/?type=song&id={music_id[0]}&br=320000' - - try: - res = request_get(URL) - except: - logger.waring("Request ERROR") - return - - data = json.loads(res) - msg = CLOUDMUSIC_REPORT_FORMAT.format( - status=data["code"], - id=data["data"][0]["id"], - br=data["data"][0]["br"], - url=data["data"][0]["url"], - md5=data["data"][0]["md5"], - ) - - c_list.append(user) - await cloudmusicRich.finish(msg) - - else: - return diff --git a/ATRI/plugins/plugin_rich/data_source.py b/ATRI/plugins/plugin_rich/data_source.py deleted file mode 100644 index 148d64b..0000000 --- a/ATRI/plugins/plugin_rich/data_source.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : data_source.py -@Time : 2020/11/21 11:11:37 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -table = 'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF' -tr = {} -for i in range(58): - tr[table[i]] = i -s = [11, 10, 3, 8, 4, 6] -xor = 177451812 -add = 8728348608 - - -def dec(x) -> int: - r = 0 - for i in range(6): - 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 ') - for i in range(6): - r[s[i]] = table[x // 58**i % 58] - return ''.join(r) |