summaryrefslogtreecommitdiff
path: root/AyaBot/plugins/pixiv.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-06-21 00:29:51 +0800
committerKyomotoi <[email protected]>2020-06-21 00:29:51 +0800
commit7d129eb9e9cca5d0a06f7e699b425306fb8ce2f6 (patch)
tree37042c9792336747942c304e7a07a49f97dbe1a0 /AyaBot/plugins/pixiv.py
parentcc9ce1bfcd695c74fd3d2dbdc39bd147d444e6b7 (diff)
downloadATRI-7d129eb9e9cca5d0a06f7e699b425306fb8ce2f6.tar.gz
ATRI-7d129eb9e9cca5d0a06f7e699b425306fb8ce2f6.tar.bz2
ATRI-7d129eb9e9cca5d0a06f7e699b425306fb8ce2f6.zip
(FIX)
Diffstat (limited to 'AyaBot/plugins/pixiv.py')
-rw-r--r--AyaBot/plugins/pixiv.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/AyaBot/plugins/pixiv.py b/AyaBot/plugins/pixiv.py
new file mode 100644
index 0000000..930c152
--- /dev/null
+++ b/AyaBot/plugins/pixiv.py
@@ -0,0 +1,37 @@
+import json
+import nonebot
+import requests
+from nonebot import on_command, CommandSession
+
+
+@on_command('pixivsearch', aliases=['p站搜索'], only_to_me=False)
+async def pixivsearch(session: CommandSession):
+ gets = session.get('gets', pormpt='请输入需要查询的pid码')
+ try:
+ URL = 'https://api.imjad.cn/pixiv/v1/?type=illust&id=' + gets
+ print(URL)
+ response = requests.request("GET", URL)
+ html = response.text
+ sr = json.loads(html)
+ i = sr["response"][0]["id"]
+ title = sr["response"][0]["title"]
+ width = sr["response"][0]["width"]
+ height = sr["response"][0]["height"]
+ userid = sr["response"][0]["user"]["id"]
+ account = sr["response"][0]["user"]["account"]
+ name = sr["response"][0]["user"]["name"]
+ await session.send(f'搜索结果如下:\nPid:{i}\nTitle:{title}\n宽高:{width},{height}\nTags:{tags}\n作者id:{userid}\n账号名称:{account}\n名称:{name}')
+ except:
+ await session.send('连接似乎失败了呢...请稍后尝试')
+
+async def _(session: CommandSession):
+ stripped_arg = session.current_arg_text.strip()
+ if session.is_first_run:
+ if stripped_arg:
+ session.state['gets'] = stripped_arg
+ return
+
+ if not stripped_arg:
+ session.pause('请输入需要查询的pid码')
+ session.state[session.current_key] = stripped_arg \ No newline at end of file