summaryrefslogtreecommitdiff
path: root/ATRI/plugins
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-08-15 23:04:06 +0800
committerKyomotoi <[email protected]>2020-08-15 23:04:06 +0800
commit6804c8bab3280c1c9bcb22c01204233c0766d1b8 (patch)
treea2fd4735eebeaa12e237f293b21da6724b8adbcc /ATRI/plugins
parent971e7f4ef3b959ba005838ea8acd128ff50bd349 (diff)
downloadATRI-6804c8bab3280c1c9bcb22c01204233c0766d1b8.tar.gz
ATRI-6804c8bab3280c1c9bcb22c01204233c0766d1b8.tar.bz2
ATRI-6804c8bab3280c1c9bcb22c01204233c0766d1b8.zip
[Fix]
Diffstat (limited to 'ATRI/plugins')
-rw-r--r--ATRI/plugins/richBISS.py47
-rw-r--r--ATRI/plugins/upload_sqlite.py137
2 files changed, 24 insertions, 160 deletions
diff --git a/ATRI/plugins/richBISS.py b/ATRI/plugins/richBISS.py
index 434e98f..79000f2 100644
--- a/ATRI/plugins/richBISS.py
+++ b/ATRI/plugins/richBISS.py
@@ -122,26 +122,27 @@ async def Fuck_CloudMusic(context):
if 0 <= now_time() < 5.5:
pass
else:
- 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
+ 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
diff --git a/ATRI/plugins/upload_sqlite.py b/ATRI/plugins/upload_sqlite.py
deleted file mode 100644
index 6a1e52a..0000000
--- a/ATRI/plugins/upload_sqlite.py
+++ /dev/null
@@ -1,137 +0,0 @@
-# -*- coding:utf-8 -*-
-import os
-import time
-import json
-import sqlite3
-import nonebot
-
-from pathlib import Path
-from nonebot import on_command, CommandSession
-
-from ATRI.modules import response # type: ignore
-
-
-bot = nonebot.get_bot()
-master = bot.config.SUPERUSERS # type: ignore
-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:
- start = time.perf_counter()
- 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 == '正常':
- if os.path.exists('ATRI/data/sqlite/setu/normal.db'):
- print('数据文件存在!')
- else:
- await session.send('数据库不存在,将在3秒后开始构建...')
- time.sleep(3)
- await session.send('开始构建数据库!')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'normal.db')
- cur = con.cursor()
- cur.execute('CREATE TABLE normal(pid PID, title TITLE, tags TAGS, account ACCOUNT, name NAME, u_id UID, user_link USERLINK, img IMG, UNIQUE(pid, title, tags, account, name, u_id, user_link, img))')
- con.commit()
- cur.close()
- con.close()
- await session.send('完成')
-
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / '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()
- con.close()
-
- elif i_tpye == '擦边球':
- if os.path.exists('ATRI/data/sqlite/setu/nearR18.db'):
- print('数据文件存在!')
- else:
- await session.send('数据库不存在,将在3秒后开始构建...')
- time.sleep(3)
- await session.send('开始构建数据库!')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db')
- cur = con.cursor()
- cur.execute('CREATE TABLE nearR18(pid PID, title TITLE, tags TAGS, account ACCOUNT, name NAME, u_id UID, user_link USERLINK, img IMG, UNIQUE(pid, title, tags, account, name, u_id, user_link, img))')
- con.commit()
- cur.close()
- con.close()
- await session.send('完成')
-
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / '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()
- con.close()
-
- elif i_tpye == 'r18':
- if os.path.exists('ATRI/data/sqlite/cloudmusic/cloudmusic.db'):
- print('数据文件存在!')
- else:
- await session.send('数据库不存在,将在3秒后开始构建...')
- time.sleep(3)
- await session.send('开始构建数据库!')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'r18.db')
- cur = con.cursor()
- cur.execute('CREATE TABLE r18(pid PID, title TITLE, tags TAGS, account ACCOUNT, name NAME, u_id UID, user_link USERLINK, img IMG, UNIQUE(pid, title, tags, account, name, u_id, user_link, img))')
- con.commit()
- cur.close()
- con.close()
- await session.send('完成')
-
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / '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()
- con.close()
-
- end = time.perf_counter()
-
- await session.send(f'数据上传完成!\n耗时: {round(end - start, 3)}s')
-
-@on_command('upload_cloudmusic', aliases = ['上传网抑语', '网抑云', '网易云'], only_to_me = False)
-async def _(session: CommandSession):
- if session.event.user_id in master:
- start = time.perf_counter()
- msg = session.event.raw_message.split(' ', 1)
- msg = msg[1]
-
- if os.path.exists('ATRI/data/sqlite/cloudmusic/cloudmusic.db'):
- print('数据文件存在!')
- else:
- await session.send('数据库不存在,将在3秒后开始构建...')
- time.sleep(3)
- await session.send('开始构建数据库!')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'cloudmusic' / 'cloudmusic.db')
- cur = con.cursor()
- cur.execute('CREATE TABLE cloudmusic(msg MSG, UNIQUE(msg))')
- con.commit()
- cur.close()
- con.close()
- await session.send('完成')
-
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'cloudmusic' / 'cloudmusic.db')
- cur = con.cursor()
- cur.execute('INSERT INTO cloudmusic VALUES ("%s")'%(msg))
- con.commit()
- con.close()
-
- end = time.perf_counter()
-
- await session.send(f'数据上传完成!\n耗时: {round(end - start, 3)}s') \ No newline at end of file