diff options
| author | Kyomotoi <1172294279@qq.com> | 2020-11-07 14:49:51 +0800 | 
|---|---|---|
| committer | Kyomotoi <1172294279@qq.com> | 2020-11-07 14:49:51 +0800 | 
| commit | c9074b24b98efe18096256ab680535f50691f67d (patch) | |
| tree | fb912e4506e478d3d61e89b2824fc83d69eae7cd /ATRI/plugins | |
| parent | 85517a82b9f787ed7c3008655c8dc04d8e6f0a30 (diff) | |
| download | ATRI-c9074b24b98efe18096256ab680535f50691f67d.tar.gz ATRI-c9074b24b98efe18096256ab680535f50691f67d.tar.bz2 ATRI-c9074b24b98efe18096256ab680535f50691f67d.zip | |
[Upload]
Diffstat (limited to 'ATRI/plugins')
| -rw-r--r-- | ATRI/plugins/plugin_admin/__init__.py | 2 | ||||
| -rw-r--r-- | ATRI/plugins/plugin_anime/__init__.py | 9 | ||||
| -rw-r--r-- | ATRI/plugins/plugin_anime/body.py | 3 | ||||
| -rw-r--r-- | ATRI/plugins/plugin_chat/__init__.py | 23 | ||||
| -rw-r--r-- | ATRI/plugins/plugin_pixiv/__init__.py | 13 | ||||
| -rw-r--r-- | ATRI/plugins/plugin_sqlite/__init__.py | 5 | ||||
| -rw-r--r-- | ATRI/plugins/plugin_utils/__init__.py | 4 | 
7 files changed, 32 insertions, 27 deletions
| diff --git a/ATRI/plugins/plugin_admin/__init__.py b/ATRI/plugins/plugin_admin/__init__.py index da749a6..e760ca9 100644 --- a/ATRI/plugins/plugin_admin/__init__.py +++ b/ATRI/plugins/plugin_admin/__init__.py @@ -147,7 +147,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:          try:              with open(data_PO, "r") as f:                  data = json.load(f) -        except: +        except FileNotFoundError:              data = {}          data[key_word] = [remind, punish, repo] diff --git a/ATRI/plugins/plugin_anime/__init__.py b/ATRI/plugins/plugin_anime/__init__.py index d01b032..8e23a7a 100644 --- a/ATRI/plugins/plugin_anime/__init__.py +++ b/ATRI/plugins/plugin_anime/__init__.py @@ -2,7 +2,7 @@  # -*- encoding: utf-8 -*-  '''  @File    :   __init__.py -@Time    :   2020/10/11 14:38:14 +@Time    :   2020/11/07 14:36:53  @Author  :   Kyomotoi  @Contact :   kyomotoiowo@gmail.com  @Github  :   https://github.com/Kyomotoi @@ -71,7 +71,8 @@ async def _(bot: Bot, event: Event, state: dict) -> None:                                             img[0])) -SaucenaoSearch_repo = on_message() +SaucenaoSearch_repo = on_message(rule=check_banlist() +                                 & check_switch(plugin_name_0))  @SaucenaoSearch_repo.handle()  # type: ignore @@ -88,7 +89,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:                  repo_info = re.findall(r"CQ:reply,id=([0-9]\S+)]", msg)                  msg_id = repo_info[0]              except Exception: -                logger.error(f"Get message_id ERROR!") +                logger.error("Get message_id ERROR!")                  await SaucenaoSearch_repo.finish(errorRepo('定位消息内容失败'))                  return @@ -218,7 +219,7 @@ async def _setu(bot: Bot, event: Event, state: dict) -> None:              title = i[1]              img = i[7] -            msg0 = f"setu info:\n" +            msg0 = "setu info:\n"              msg0 += f"Title: {title}\n"              msg0 += f"Pid: {pid}\n"              msg0 += f"[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]" diff --git a/ATRI/plugins/plugin_anime/body.py b/ATRI/plugins/plugin_anime/body.py index a68dc48..d7dae84 100644 --- a/ATRI/plugins/plugin_anime/body.py +++ b/ATRI/plugins/plugin_anime/body.py @@ -17,6 +17,7 @@ from utils.utils_request import request_get  class SauceNAO: +    """搜图请求主体"""      def __init__(self,                   api_key,                   output_type=2, @@ -54,7 +55,7 @@ def resultRepo(user: str, key: str, img_url: str):      print(data)      msg0 += f'[CQ:at,qq={user}]\n' -    msg0 += f"SauceNAO INFO:\n" +    msg0 += "SauceNAO INFO:\n"      msg0 += f"[CQ:image,file={data['header'].get('thumbnail', None)}]\n"      msg0 += f"Like:{data['header'].get('similarity', 0)}%\n"      msg0 += f"Title:{data['data'].get('title', None)}\n" diff --git a/ATRI/plugins/plugin_chat/__init__.py b/ATRI/plugins/plugin_chat/__init__.py index 0a718b0..9d70f7a 100644 --- a/ATRI/plugins/plugin_chat/__init__.py +++ b/ATRI/plugins/plugin_chat/__init__.py @@ -2,7 +2,7 @@  # -*- encoding: utf-8 -*-  '''  @File    :   __init__.py -@Time    :   2020/10/11 14:38:38 +@Time    :   2020/11/07 14:24:57  @Author  :   Kyomotoi  @Contact :   kyomotoiowo@gmail.com  @Github  :   https://github.com/Kyomotoi @@ -13,6 +13,7 @@ __author__ = 'kyomotoi'  import json  from pathlib import Path  from random import choice +from requests import exceptions   from nonebot.log import logger  from nonebot.rule import to_me @@ -104,7 +105,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:          await groupEvent.finish(              f'好欸!事新人[CQ:at,qq={event.raw_event["user_id"]}]'  # type: ignore          )  # type: ignore -        await groupEvent.finish(f"在下 ATRI,你可以叫我 亚托莉 或 アトリ !~w") +        await groupEvent.finish("在下 ATRI,你可以叫我 亚托莉 或 アトリ !~w")      elif event.raw_event[  # type: ignore              "notice_type"] == "group_decrease": @@ -113,16 +114,16 @@ async def _(bot: Bot, event: Event, state: dict) -> None:          ) -# 舆情监听系统 -listenPublicOpinion = on_message() -file_PO = Path( -    '.') / 'ATRI' / 'plugins' / 'plugin_chat' / 'public_opinion.json' +# # 舆情监听系统 +# listenPublicOpinion = on_message() +# file_PO = Path( +#     '.') / 'ATRI' / 'plugins' / 'plugin_chat' / 'public_opinion.json' -@groupEvent.handle()  # type: ignore -async def _(bot: Bot, event: Event, state: dict) -> None: -    with open(file_PO, 'r') as f: -        data = json.load(f) +# @groupEvent.handle()  # type: ignore +# async def _(bot: Bot, event: Event, state: dict) -> None: +#     with open(file_PO, 'r') as f: +#         data = json.load(f)  # 口臭一下 @@ -151,7 +152,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:          try:              msg = request_api_text(URL) -        except: +        except exceptions:              await fxxkMe.finish(errorRepo("请求错误"))          await fxxkMe.finish(msg) 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): diff --git a/ATRI/plugins/plugin_sqlite/__init__.py b/ATRI/plugins/plugin_sqlite/__init__.py index 9108b34..ef03bab 100644 --- a/ATRI/plugins/plugin_sqlite/__init__.py +++ b/ATRI/plugins/plugin_sqlite/__init__.py @@ -14,6 +14,7 @@ import os  import json  import sqlite3  from pathlib import Path +from aiohttp import client_exceptions  from nonebot.plugin import on_command  from nonebot.permission import SUPERUSER  from nonebot.adapters.cqhttp import Bot, Event @@ -61,7 +62,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:      try:          info = json.loads(await aio_get_bytes(URL)) -    except: +    except client_exceptions:          await UploadSetu.finish(errorRepo("网络请求出错"))      info = info["response"][0] @@ -70,7 +71,7 @@ async def _(bot: Bot, event: Event, state: dict) -> None:      account = info["user"]["account"]      name = info["user"]["name"]      u_id = info["user"]["id"] -    user_link = f'https://www.pixiv.net/users/' + f'{u_id}' +    user_link = f'https://www.pixiv.net/users/{u_id}'      img = f'https://pixiv.cat/{pid}.jpg'      data_setu = (f'{pid}', f'{title}', f'{tags}', f'{account}', f'{name}', diff --git a/ATRI/plugins/plugin_utils/__init__.py b/ATRI/plugins/plugin_utils/__init__.py index a35bb41..3c813cb 100644 --- a/ATRI/plugins/plugin_utils/__init__.py +++ b/ATRI/plugins/plugin_utils/__init__.py @@ -1,13 +1,13 @@  #!/usr/bin/env python3  # -*- encoding: utf-8 -*- +  '''  @File    :   __init__.py -@Time    :   2020/10/17 21:16:59 +@Time    :   2020/11/07 14:20:08  @Author  :   Kyomotoi  @Contact :   kyomotoiowo@gmail.com  @Github  :   https://github.com/Kyomotoi  @License :   Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -@Docs    :   Thanks for mnixry idea! fork from https://github.com/mnixry/coolQPythonBot  '''  __author__ = 'kyomotoi' | 
