From c9074b24b98efe18096256ab680535f50691f67d Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Sat, 7 Nov 2020 14:49:51 +0800 Subject: [Upload] --- ATRI/plugins/plugin_pixiv/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ATRI/plugins/plugin_pixiv') diff --git a/ATRI/plugins/plugin_pixiv/__init__.py b/ATRI/plugins/plugin_pixiv/__init__.py index e8a66df..3c5b849 100644 --- a/ATRI/plugins/plugin_pixiv/__init__.py +++ b/ATRI/plugins/plugin_pixiv/__init__.py @@ -2,7 +2,7 @@ # -*- encoding: utf-8 -*- ''' @File : __init__.py -@Time : 2020/10/11 14:38:49 +@Time : 2020/11/07 14:31:30 @Author : Kyomotoi @Contact : kyomotoiowo@gmail.com @Github : https://github.com/Kyomotoi @@ -12,6 +12,7 @@ __author__ = 'kyomotoi' import re import json +from requests import exceptions from nonebot.plugin import on_command from nonebot.adapters.cqhttp import Bot, Event @@ -56,11 +57,11 @@ async def _(bot: Bot, event: Event, state: dict) -> None: try: data = json.loads(request_get(URL)) - except: + except exceptions: await pixivSearchIMG.finish(errorRepo("请求数据失败")) msg0 = f'[CQ:at,qq={state["user"]}]\n' - msg0 += f"Search result:\n" + msg0 += "Search result:\n" msg0 += f"Pid: {pid}\n" msg0 += f'Title {data["response"][0]["title"]}\n' msg0 += f'W&H: {data["response"][0]["width"]}x{data["response"][0]["height"]}\n' @@ -110,7 +111,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None: try: data = json.loads(request_get(URL)) - except: + except exceptions: await pixivSearchAuthor.finish(errorRepo("请求网络失败")) for i in range(0, 3): @@ -126,7 +127,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None: for i in result: t += 1 - msg = f"\n---------------\n" + msg = "\n---------------\n" msg += f"({t})\n" msg += f"Pid: {i[1][0]}\n{i[1][1]}" msg0 += msg @@ -150,7 +151,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None: try: data = json.loads(request_get(URL)) - except: + except exceptions: await pixivRank.finish(errorRepo("网络请求失败")) for i in range(0, 5): -- cgit v1.2.3