From 2c676bdd60b7cafe988272ecdfceb4b275f7d05f Mon Sep 17 00:00:00 2001 From: justundertaker <806792561@qq.com> Date: Tue, 25 Jan 2022 22:53:38 +0800 Subject: [PATCH] =?UTF-8?q?:arrow=5Fdown:=E9=99=8D=E4=BD=8E=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E8=87=B33.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++++++------ src/managers/admin_manager/data_source.py | 6 +++--- src/managers/group_manager/data_source.py | 4 ++-- src/managers/server_manager/_jx3_event.py | 4 ++-- src/managers/server_manager/_websocket.py | 3 ++- src/modules/group_info.py | 8 ++++---- src/modules/plugin_info.py | 4 ++-- src/modules/ticket_info.py | 4 ++-- src/modules/user_info.py | 3 ++- src/plugins/jx3_search/data_source.py | 10 +++++----- src/plugins/jx3_search/model.py | 4 ++-- src/plugins/weather/_weather.py | 4 ++-- src/utils/config.py | 4 ++-- 13 files changed, 36 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 02432a7e..ecedc4ca 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ _✨基于[nonebot2](https://github.com/nonebot/nonebot2)的剑网三群聊机

-license +license @@ -33,9 +33,9 @@ _✨基于[nonebot2](https://github.com/nonebot/nonebot2)的剑网三群聊机 ## 部署机器人 ### 安装环境 -**项目需要python环境,且需要[python3.9+](https://www.python.org/downloads/)。** +**项目需要python环境,且需要[python3.8+](https://www.python.org/downloads/),可以自行选择python版本。** ```bash -apt-get install python3.9 +apt-get install python3.8 ``` **QQ协议端采用[go-cqhttp](https://github.com/Mrs4s/go-cqhttp)。** @@ -157,10 +157,10 @@ servers: universal: ws://127.0.0.1:8080/onebot/v11/ws ``` 这主要是nb2升级到了beta1,ws地址发生了变化。 -### 1.linux下安装python3.9 -linux系统推荐使用ubuntu,自带的apt可以直接获取python3.9 +### 1.linux下安装python +linux系统推荐使用ubuntu20+,自带python3.8,而且apt可以获取3.9+ ```bash -sudo apt-get install python3.9 +sudo apt-get install python3.8 ``` 如果需要编译安装,请自行查找相关资料 ### 2.python虚拟环境 diff --git a/src/managers/admin_manager/data_source.py b/src/managers/admin_manager/data_source.py index 96f0a831..8bdd518f 100644 --- a/src/managers/admin_manager/data_source.py +++ b/src/managers/admin_manager/data_source.py @@ -1,4 +1,4 @@ -from typing import Tuple +from typing import List, Tuple from httpx import AsyncClient from src.modules.group_info import GroupInfo @@ -6,7 +6,7 @@ from src.utils.config import config -async def get_group_list() -> list[dict]: +async def get_group_list() -> List[dict]: ''' 获取群数据 @@ -32,7 +32,7 @@ async def set_bot_status(group_id: int, status: str): await GroupInfo.set_status(group_id, status) -async def get_ticket_list() -> list[dict]: +async def get_ticket_list() -> List[dict]: '''获取ticket列表''' return await TicketInfo.get_all() diff --git a/src/managers/group_manager/data_source.py b/src/managers/group_manager/data_source.py index fd61529a..991189fc 100644 --- a/src/managers/group_manager/data_source.py +++ b/src/managers/group_manager/data_source.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import Literal, Optional +from typing import List, Literal, Optional from httpx import AsyncClient from nonebot.adapters.onebot.v11 import Message, MessageSegment @@ -50,7 +50,7 @@ async def get_notice_status(group_id: int, notice_type: Literal["welcome_status" return await GroupInfo.get_config_status(group_id, notice_type) -async def _message_encoder(message: Message, path: Path) -> list[dict]: +async def _message_encoder(message: Message, path: Path) -> List[dict]: '''将message编码成json格式,将图片保存本地''' req_data = [] index = 0 diff --git a/src/managers/server_manager/_jx3_event.py b/src/managers/server_manager/_jx3_event.py index 14d2c9e0..e4d6625e 100644 --- a/src/managers/server_manager/_jx3_event.py +++ b/src/managers/server_manager/_jx3_event.py @@ -1,6 +1,6 @@ import time from datetime import datetime -from typing import Optional +from typing import List, Optional from nonebot.adapters import Event as BaseEvent from nonebot.adapters.onebot.v11.message import Message @@ -326,7 +326,7 @@ class FuyaoNamedEvent(RecvEvent): '''扶摇点名事件''' __event__ = "WsRecv.FuyaoNamed" message_type = "FuyaoNamed" - names: Optional[list[str]] + names: Optional[List[str]] '''点名角色组''' time: Optional[str] '''点名时间''' diff --git a/src/managers/server_manager/_websocket.py b/src/managers/server_manager/_websocket.py index 42bb401b..161fc0d3 100644 --- a/src/managers/server_manager/_websocket.py +++ b/src/managers/server_manager/_websocket.py @@ -1,5 +1,6 @@ import asyncio import json +from typing import Dict import websockets from nonebot import get_bots @@ -78,7 +79,7 @@ async def _handle_msg(self, message: str): for _, one_bot in bots.items(): await handle_event(one_bot, event) - def _handle_first_recv(self, data: dict[str, str]): + def _handle_first_recv(self, data: Dict[str, str]): '''处理首次接收事件''' def _to_bool(string: str) -> bool: return (string == "已开启") diff --git a/src/modules/group_info.py b/src/modules/group_info.py index 8ff6a477..b0c9cd09 100644 --- a/src/modules/group_info.py +++ b/src/modules/group_info.py @@ -1,5 +1,5 @@ import json -from typing import Literal, Optional, Tuple +from typing import List, Literal, Optional, Tuple from src.utils.config import config from tortoise import fields @@ -194,7 +194,7 @@ async def get_meau_data(cls, group_id: int) -> dict: return data @classmethod - async def set_notice_msg(cls, group_id: int, notice_type: Literal["晚安通知", "离群通知", "进群通知"], message: list[dict]): + async def set_notice_msg(cls, group_id: int, notice_type: Literal["晚安通知", "离群通知", "进群通知"], message: List[dict]): '''设置通知内容''' _message = json.dumps(message, ensure_ascii=False) record, _ = await cls.get_or_create(group_id=group_id) @@ -211,7 +211,7 @@ async def set_notice_msg(cls, group_id: int, notice_type: Literal["晚安通知" await record.save(update_fields=["welcome_text"]) @classmethod - async def get_notice_msg(cls, group_id: int, notice_type: Literal["晚安通知", "离群通知", "进群通知"]) -> list[dict]: + async def get_notice_msg(cls, group_id: int, notice_type: Literal["晚安通知", "离群通知", "进群通知"]) -> List[dict]: '''获取通知内容''' record, _ = await cls.get_or_create(group_id=group_id) if notice_type == "晚安通知": @@ -227,7 +227,7 @@ async def delete_group(cls, group_id: int): await cls.filter(group_id=group_id).delete() @classmethod - async def get_group_list(cls) -> list[dict]: + async def get_group_list(cls) -> List[dict]: '''获取群列表数据''' return await cls.all().values("group_id", "group_name", "sign_nums", "server", "robot_status", "robot_active") diff --git a/src/modules/plugin_info.py b/src/modules/plugin_info.py index 18bdbb6d..386b6123 100644 --- a/src/modules/plugin_info.py +++ b/src/modules/plugin_info.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import List, Optional from tortoise import fields from tortoise.models import Model @@ -72,7 +72,7 @@ async def set_plugin_status(cls, group_id: int, module_name: str, status: bool) return False @classmethod - async def get_meau_data(cls, group_id: int) -> list[dict]: + async def get_meau_data(cls, group_id: int) -> List[dict]: '''获取菜单数据''' return await cls.filter(group_id=group_id).order_by("plugin_name").values("plugin_name", "command", "usage", "status") diff --git a/src/modules/ticket_info.py b/src/modules/ticket_info.py index 13ea2685..cfa6132c 100644 --- a/src/modules/ticket_info.py +++ b/src/modules/ticket_info.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import List, Optional from tortoise import fields from tortoise.models import Model @@ -45,7 +45,7 @@ async def append_ticket(cls, ticket: str) -> bool: return not flag @classmethod - async def get_all(cls) -> list[dict]: + async def get_all(cls) -> List[dict]: ''' :说明 获取所有ticket diff --git a/src/modules/user_info.py b/src/modules/user_info.py index 74dd78a1..78a4829f 100644 --- a/src/modules/user_info.py +++ b/src/modules/user_info.py @@ -1,5 +1,6 @@ import random from datetime import date +from typing import Dict from tortoise import fields from tortoise.models import Model @@ -45,7 +46,7 @@ async def sign_in(cls, friendly_add: int, gold_base: int, lucky_gold: int - ) -> dict[str, int]: + ) -> Dict[str, int]: ''' :说明 设置签到 diff --git a/src/plugins/jx3_search/data_source.py b/src/plugins/jx3_search/data_source.py index 2c5390fc..27bd9d9f 100644 --- a/src/plugins/jx3_search/data_source.py +++ b/src/plugins/jx3_search/data_source.py @@ -1,6 +1,6 @@ import time from datetime import datetime -from typing import Optional, Tuple +from typing import List, Optional, Tuple from src.modules.group_info import GroupInfo from src.utils.log import logger @@ -67,7 +67,7 @@ async def get_data_from_api(app_name: str, group_id: int, params: dict, need_tic # ------------------------------------------------------------- -def handle_data_price(data: list[list[dict]]) -> dict: +def handle_data_price(data: List[List[dict]]) -> dict: '''处理物价数据''' req_data = {} for one_data in data: @@ -80,7 +80,7 @@ def handle_data_price(data: list[list[dict]]) -> dict: return req_data -def handle_data_serendipity(data: list[dict]) -> list[dict]: +def handle_data_serendipity(data: List[dict]) -> List[dict]: '''处理奇遇统计''' req_data = [] for one_data in data: @@ -98,7 +98,7 @@ def handle_data_serendipity(data: list[dict]) -> list[dict]: return req_data -def handle_data_serendipity_list(data: list[dict]) -> list[dict]: +def handle_data_serendipity_list(data: List[dict]) -> List[dict]: '''处理奇遇统计数据''' req_data = [] for one_data in data: @@ -116,7 +116,7 @@ def handle_data_serendipity_list(data: list[dict]) -> list[dict]: return req_data -def handle_data_serendipity_summary(data: list[dict]) -> list[dict]: +def handle_data_serendipity_summary(data: List[dict]) -> List[dict]: '''处理奇遇汇总数据''' req_data = [] for _data in data: diff --git a/src/plugins/jx3_search/model.py b/src/plugins/jx3_search/model.py index 0a25f346..057f5901 100644 --- a/src/plugins/jx3_search/model.py +++ b/src/plugins/jx3_search/model.py @@ -1,5 +1,5 @@ import time -from typing import Optional, Tuple, Union +from typing import Dict, Optional, Tuple, Union from httpx import AsyncClient from src.modules.search_record import SearchRecord @@ -62,7 +62,7 @@ class SearchManager(object): _main_site: str '''jx3api主站url''' - _app_dict: dict[str, dict[str, Union[str, int]]] + _app_dict: Dict[str, Dict[str, Union[str, int]]] '''app字典''' def __init__(self): diff --git a/src/plugins/weather/_weather.py b/src/plugins/weather/_weather.py index 1db38e67..4ff527c3 100644 --- a/src/plugins/weather/_weather.py +++ b/src/plugins/weather/_weather.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Optional, Tuple +from typing import Dict, List, Optional, Tuple from httpx import AsyncClient from src.utils.config import config @@ -53,7 +53,7 @@ def __init__(self): self._client = AsyncClient() @classmethod - def _handle_days(cls, days: list[dict[str, str]]) -> dict: + def _handle_days(cls, days: List[Dict[str, str]]) -> dict: '''处理days数据,增加week,date字段''' week_map = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"] data = [] diff --git a/src/utils/config.py b/src/utils/config.py index d4a5a838..dccd6ace 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import Union +from typing import Dict, Union import yaml @@ -14,7 +14,7 @@ def __new__(cls, *args, **kwargs): cls._instance = orig.__new__(cls, *args, **kwargs) return cls._instance - def __getattr__(self, item) -> dict[str, Union[str, int, bool]]: + def __getattr__(self, item) -> Dict[str, Union[str, int, bool]]: '''获取配置''' value = self._config.get(item) if value: