diff options
Diffstat (limited to 'ATRI')
-rw-r--r-- | ATRI/plugins/bilibili.py | 102 | ||||
-rw-r--r-- | ATRI/plugins/cloudmusic.py | 81 | ||||
-rw-r--r-- | ATRI/plugins/upload_setu.py | 128 | ||||
-rw-r--r-- | ATRI/sqlite/cloudmusic/cloudmusic.db | bin | 0 -> 8192 bytes | |||
-rw-r--r-- | ATRI/sqlite/setu/nearR18.db | bin | 0 -> 8192 bytes | |||
-rw-r--r-- | ATRI/sqlite/setu/normal.db | bin | 0 -> 8192 bytes | |||
-rw-r--r-- | ATRI/sqlite/setu/r18.db | bin | 0 -> 8192 bytes |
7 files changed, 128 insertions, 183 deletions
diff --git a/ATRI/plugins/bilibili.py b/ATRI/plugins/bilibili.py deleted file mode 100644 index a298784..0000000 --- a/ATRI/plugins/bilibili.py +++ /dev/null @@ -1,102 +0,0 @@ -# -*- coding:utf-8 -*- -import json -import nonebot -from orjson import loads -from html import unescape - -from ATRI.modules import response # type: ignore - - -REPORT_FORMAT = """({aid})信息如下: -Title: {title} -aid: {aid} -bid: {bid} -观看: {view} 点赞: {like} -投币: {coin} 转发: {share} -观看链接: -{aid_link} -{bid_link}""" - - -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): - r=0 - for i in range(6): - r+=tr[x[s[i]]]*58**i - return (r-add)^xor - -def enc(x): - 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) - - -def check(string, sub_str): - if (string.find(sub_str) == -1): - ch = 0 - return ch - else: - ch = 1 - return ch - - [email protected]_natural_language(only_to_me = False) -async def fk_tx_app_bilibili(session: nonebot.NLPSession): - rich_message = [x for x in session.ctx['message'] if x.get('type') == 'rich'] - - if not rich_message: - return - - rich_message = rich_message[0]['data'] - - xch = '小程序' - bili = '哔哩哔哩' - if check(rich_message['title'], xch) == 0: - return - if check(rich_message['title'], bili) == 0: - return - - rich_message = rich_message['content'] - data = loads(unescape(rich_message)) - - if 'detail_1' not in str(rich_message): - return - - URL = data['detail_1']['qqdocurl'] - rep = URL.replace('?', '/') - rep = rep.split('/') - biv = rep[4] - - aid = str(dec(biv)) - - url = f'https://api.imjad.cn/bilibili/v2/?aid={aid}' - ad = 'av' + aid - - dc = json.loads(response.request_api(url)) - - pic = dc["data"]["pic"] - - await session.send(REPORT_FORMAT.format( - title = dc["data"]["title"], - - view = dc["data"]["stat"]["view"], - coin = dc["data"]["stat"]["coin"], - share = dc["data"]["stat"]["share"], - like = dc["data"]["stat"]["like"], - - bid = biv, - bid_link = dc["data"]["short_link"], - - aid = ad, - aid_link = f'https://b23.tv/{ad}' - ) - ) diff --git a/ATRI/plugins/cloudmusic.py b/ATRI/plugins/cloudmusic.py deleted file mode 100644 index ad85cad..0000000 --- a/ATRI/plugins/cloudmusic.py +++ /dev/null @@ -1,81 +0,0 @@ -import json -import nonebot -from orjson import loads -from html import unescape - -from ATRI.modules import response - -REPORT_FORMAT = """Status: {status} -Song id: {id} -Br: {br} -Download: {url} -MD5: {md5}""" - - [email protected]_natural_language(only_to_me = False) -async def fk_tx_app_cloudmusic(session: nonebot.NLPSession): - rich_message = [x for x in session.ctx['message'] if x.get('type') == 'rich'] - - if not rich_message: - return - - rich_message = rich_message[0]['data']['content'] - - if '网易云音乐' not in str(rich_message): - return - - if 'music' not in str(rich_message): - return - - data = loads(unescape(rich_message)) - - URL = data['music']['jumpUrl'] - rep = URL.split('/') - wid = rep[4] - - url = f'https://api.imjad.cn/cloudmusic/?type=song&id={wid}&br=320000' - print(url) - - dc = json.loads(response.request_api(url)) - - await session.send( - REPORT_FORMAT.format( - status = dc["code"], - id = dc["data"][0]["id"], - br = dc["data"][0]["br"], - url = dc["data"][0]["url"], - md5 = dc["data"][0]["md5"], - ) - ) - - [email protected]_natural_language(only_to_me = False) -async def cloudmusic_link(session: nonebot.NLPSession): - share_message = [x for x in session.ctx['message'] if x.get('type') == 'share'] - - if not share_message: - return - - share_message = share_message[0]['data']['url'] - - if 'music.163.com' not in str(share_message): - return - - rep = share_message.replace('=', '/') - rep = rep.replace('&', '/') - wid = rep[4] - - url = f'https://api.imjad.cn/cloudmusic/?type=song&id={wid}&br=320000' - print(url) - - dc = json.loads(response.request_api(url)) - - await session.send( - REPORT_FORMAT.format( - status = dc["code"], - id = dc["data"][0]["id"], - br = dc["data"][0]["br"], - url = dc["data"][0]["url"], - md5 = dc["data"][0]["md5"], - ) - )
\ No newline at end of file diff --git a/ATRI/plugins/upload_setu.py b/ATRI/plugins/upload_setu.py new file mode 100644 index 0000000..78158c3 --- /dev/null +++ b/ATRI/plugins/upload_setu.py @@ -0,0 +1,128 @@ +# -*- coding:utf-8 -*- +import time +import json +import sqlite3 +import nonebot + +from nonebot import on_command, CommandSession +from nonebot import session + +from ATRI.modules import response # type: ignore + + +bot = nonebot.get_bot() +master = bot.config.SUPERUSERS # type: ignore +path_setu = f'ATRI\\splite\\setu\\' +path_cloudmusic = f'ATRI\\splite\\cloudmusic\\' +url = f'https://api.imjad.cn/pixiv/v1/?type=illust&id=' + + +@on_command('upload_setu', aliases = ['上传涩图'], only_to_me = False) +async def _(session: CommandSession): + if session.event.user_id in master: + msg = session.event.raw_message.split(' ', 2) + print(msg) + i_tpye = msg[1] + pid = msg[2] + + URL = url + pid + + dc = json.loads(response.request_api(URL)) + if not dc: + session.finish('ATRI在尝试解析数据时出问题...等会再试试吧...') + title = dc["response"][0]["title"] + tags = dc["response"][0]["tags"] + account = dc["response"][0]["user"]["account"] + name = dc["response"][0]["user"]["name"] + u_id = dc["response"][0]["user"]["id"] + user_link = f'https://www.pixiv.net/users/' + f'{u_id}' + img = f'https://pixiv.cat/{pid}.jpg' + + if i_tpye == '正常': + con = sqlite3.connect(path_setu + 'normal.db') + cur = con.cursor() + + cur.execute('INSERT INTO normal VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")'%(pid, title, tags, account, name, u_id, user_link, img)) + con.commit() + + print('success!') + time.sleep(0.5) + con.close() + + elif i_tpye == '擦边球': + con = sqlite3.connect(path_setu + 'nearR18.db') + cur = con.cursor() + + cur.execute('INSERT INTO nearR18 VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")'%(pid, title, tags, account, name, u_id, user_link, img)) + con.commit() + + print('success!') + time.sleep(0.5) + con.close() + + elif i_tpye == 'r18': + con = sqlite3.connect(path_setu + 'r18.db') + cur = con.cursor() + + cur.execute('INSERT INTO r18 VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")'%(pid, title, tags, account, name, u_id, user_link, img)) + con.commit() + + print('success!') + time.sleep(0.5) + con.close() + + await session.send('数据上传完成!') + +@on_command('upload_cloudmusic', aliases = ['上传网抑语', '网抑云', '网易云'], only_to_me = False) +async def _(session: CommandSession): + if session.event.user_id in master: + msg = session.event.raw_message.split(' ', 1) + msg = msg[1] + + con = sqlite3.connect(path_cloudmusic + 'cloudmusic.db') + cur = con.cursor() + + cur.execute('INSERT INTO cloudmusic VALUES ("%s")'%(msg)) + con.commit() + + print('success!') + time.sleep(0.5) + con.close() + + await session.send('数据上传完成!') + + +@on_command('data_list', aliases = ['查看上传数据', '数据总量'], only_to_me = False) +async def _(session: CommandSession): + con = sqlite3.connect(path_setu + 'normal.db') # setu-normal + cur = con.cursor() + cur.execute("select * from normal") + data_normal = len(cur.fetchall()) + con.close() + + con = sqlite3.connect(path_setu + 'nearR18.db') # setu-nearR18 + cur = con.cursor() + cur.execute("select * from nearR18") + data_nearR18 = len(cur.fetchall()) + con.close() + + con = sqlite3.connect(path_setu + 'r18.db') # setu-r18 + cur = con.cursor() + cur.execute("select * from r18") + data_r18 = len(cur.fetchall()) + con.close() + + con = sqlite3.connect(path_cloudmusic + 'cloudmusic.db') # cloudmusic + cur = con.cursor() + cur.execute("select * from cloudmusic") + data_cloudmusic = len(cur.fetchall()) + con.close() + + await session.send( + f"""目前ATRI数据库收录了: + 涩图: + normal: {data_normal} + nearR18: {data_nearR18} + r18:{data_r18} + 网抑云语录:{data_cloudmusic}""" + )
\ No newline at end of file diff --git a/ATRI/sqlite/cloudmusic/cloudmusic.db b/ATRI/sqlite/cloudmusic/cloudmusic.db Binary files differnew file mode 100644 index 0000000..f6959a3 --- /dev/null +++ b/ATRI/sqlite/cloudmusic/cloudmusic.db diff --git a/ATRI/sqlite/setu/nearR18.db b/ATRI/sqlite/setu/nearR18.db Binary files differnew file mode 100644 index 0000000..627646c --- /dev/null +++ b/ATRI/sqlite/setu/nearR18.db diff --git a/ATRI/sqlite/setu/normal.db b/ATRI/sqlite/setu/normal.db Binary files differnew file mode 100644 index 0000000..92d3b64 --- /dev/null +++ b/ATRI/sqlite/setu/normal.db diff --git a/ATRI/sqlite/setu/r18.db b/ATRI/sqlite/setu/r18.db Binary files differnew file mode 100644 index 0000000..38a7b37 --- /dev/null +++ b/ATRI/sqlite/setu/r18.db |