summaryrefslogtreecommitdiff
path: root/ATRI/plugins/richBISS.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-08-24 18:09:04 +0800
committerKyomotoi <[email protected]>2020-08-24 18:09:04 +0800
commit27459db32dee5c70756aca40a4dfad8f7f90ad7b (patch)
tree68660052a2b5b3f89745bb12aaa9099aa5245fb7 /ATRI/plugins/richBISS.py
parentc413c33b246bb49e31f070d781a8515bb61f7909 (diff)
downloadATRI-27459db32dee5c70756aca40a4dfad8f7f90ad7b.tar.gz
ATRI-27459db32dee5c70756aca40a4dfad8f7f90ad7b.tar.bz2
ATRI-27459db32dee5c70756aca40a4dfad8f7f90ad7b.zip
[Update]
Diffstat (limited to 'ATRI/plugins/richBISS.py')
-rw-r--r--ATRI/plugins/richBISS.py167
1 files changed, 68 insertions, 99 deletions
diff --git a/ATRI/plugins/richBISS.py b/ATRI/plugins/richBISS.py
index 949bcf0..f60d7d0 100644
--- a/ATRI/plugins/richBISS.py
+++ b/ATRI/plugins/richBISS.py
@@ -5,6 +5,7 @@ from pathlib import Path
from datetime import datetime
from ATRI.modules import response # type: ignore
+from ATRI.modules.funcControl import checkNoob # type: ignore
bot = nonebot.get_bot()
@@ -52,62 +53,46 @@ def enc(x):
async def Fuck_bili_rich(context):
user = str(context["user_id"])
group = context["group_id"]
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f:
- data1 = json.load(f)
- except:
- data1 = {}
-
- if str(group) in data.keys():
- pass
- else:
- if user in data1.keys():
+ if checkNoob(user, group):
+ if 0 <= now_time() < 5.5:
pass
else:
- if 0 <= now_time() < 5.5:
- pass
- else:
- msg = str(context["message"])
- pattern = re.compile(r"BV\S+\?")
- bv = re.findall(pattern, msg)
- if bv:
- bv = bv[0]
- bv = bv.replace('?', '')
- print(bv)
-
- aid = str(dec(bv))
- ad = 'av' + aid
- URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}'
-
- try:
- res = response.request_api(URL)
- mg = json.loads(res)
- msg = BILI_REPORT_FORMAT.format(
- title = mg["data"]["title"],
-
- view = mg["data"]["stat"]["view"],
- coin = mg["data"]["stat"]["coin"],
- share = mg["data"]["stat"]["share"],
- like = mg["data"]["stat"]["like"],
-
- bid = mg["data"]["bvid"],
- bid_link = mg["data"]["short_link"],
-
- aid = ad,
- aid_link = f'https://b23.tv/{ad}'
- )
-
- await bot.send_msg( # type: ignore
- group_id = group,
- message = msg
- )
- except:
- pass
+ msg = str(context["message"])
+ pattern = re.compile(r"BV\S+\?")
+ bv = re.findall(pattern, msg)
+ if bv:
+ bv = bv[0]
+ bv = bv.replace('?', '')
+ print(bv)
+
+ aid = str(dec(bv))
+ ad = 'av' + aid
+ URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}'
+
+ try:
+ res = response.request_api(URL)
+ mg = json.loads(res)
+ msg = BILI_REPORT_FORMAT.format(
+ title = mg["data"]["title"],
+
+ view = mg["data"]["stat"]["view"],
+ coin = mg["data"]["stat"]["coin"],
+ share = mg["data"]["stat"]["share"],
+ like = mg["data"]["stat"]["like"],
+
+ bid = mg["data"]["bvid"],
+ bid_link = mg["data"]["short_link"],
+
+ aid = ad,
+ aid_link = f'https://b23.tv/{ad}'
+ )
+
+ await bot.send_msg( # type: ignore
+ group_id = group,
+ message = msg
+ )
+ except:
+ pass
REPORT_FORMAT = """Status: {status}
@@ -120,50 +105,34 @@ MD5: {md5}"""
async def Fuck_CloudMusic(context):
user = str(context["user_id"])
group = context["group_id"]
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f:
- data1 = json.load(f)
- except:
- data1 = {}
-
- if str(group) in data.keys():
- pass
- else:
- if user in data1.keys():
+ if checkNoob(user, group):
+ if 0 <= now_time() < 5.5:
pass
else:
- if 0 <= now_time() < 5.5:
- pass
- else:
- msg = str(context["message"])
- pattern = re.compile(r"song\S+\/|id=\S+\&")
- music_id = re.findall(pattern, msg)
- if 'music.163.com' in 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'
- print(URL)
-
- try:
- res = response.request_api(URL)
- mg = json.loads(res)
-
- msg = REPORT_FORMAT.format(
- status = mg["code"],
- id = mg["data"][0]["id"],
- br = mg["data"][0]["br"],
- url = mg["data"][0]["url"],
- md5 = mg["data"][0]["md5"],
- )
- await bot.send_msg(
- group_id = group,
- message = msg
- ) # type: ignore
- except:
- pass \ No newline at end of file
+ msg = str(context["message"])
+ pattern = re.compile(r"song\S+\/|id=\S+\&")
+ music_id = re.findall(pattern, msg)
+ if 'music.163.com' in 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'
+ print(URL)
+
+ try:
+ res = response.request_api(URL)
+ mg = json.loads(res)
+
+ msg = REPORT_FORMAT.format(
+ status = mg["code"],
+ id = mg["data"][0]["id"],
+ br = mg["data"][0]["br"],
+ url = mg["data"][0]["url"],
+ md5 = mg["data"][0]["md5"],
+ )
+ await bot.send_msg(
+ group_id = group,
+ message = msg
+ ) # type: ignore
+ except:
+ pass \ No newline at end of file