Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
⬇️降低依赖至3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
JustUndertaker committed Jan 25, 2022
1 parent f03f260 commit 2c676bd
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 34 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _✨基于[nonebot2](https://github.com/nonebot/nonebot2)的剑网三群聊机

<p align="center">
<a href="https://www.python.org/">
<img src="https://img.shields.io/badge/python-3.9%2B-blue" alt="license"></a>
<img src="https://img.shields.io/badge/python-3.8%2B-blue" alt="license"></a>
<a href="https://github.com/nonebot/nonebot2">
<img src="https://img.shields.io/badge/nonebot-2.0.0b1-yellow"></a>
<a href="https://github.com/Mrs4s/go-cqhttp">
Expand All @@ -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)**

Expand Down Expand Up @@ -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虚拟环境
Expand Down
6 changes: 3 additions & 3 deletions src/managers/admin_manager/data_source.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Tuple
from typing import List, Tuple

from httpx import AsyncClient
from src.modules.group_info import GroupInfo
from src.modules.ticket_info import TicketInfo
from src.utils.config import config


async def get_group_list() -> list[dict]:
async def get_group_list() -> List[dict]:
'''
获取群数据
Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions src/managers/group_manager/data_source.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/managers/server_manager/_jx3_event.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -326,7 +326,7 @@ class FuyaoNamedEvent(RecvEvent):
'''扶摇点名事件'''
__event__ = "WsRecv.FuyaoNamed"
message_type = "FuyaoNamed"
names: Optional[list[str]]
names: Optional[List[str]]
'''点名角色组'''
time: Optional[str]
'''点名时间'''
Expand Down
3 changes: 2 additions & 1 deletion src/managers/server_manager/_websocket.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import json
from typing import Dict

import websockets
from nonebot import get_bots
Expand Down Expand Up @@ -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 == "已开启")
Expand Down
8 changes: 4 additions & 4 deletions src/modules/group_info.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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 == "晚安通知":
Expand All @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions src/modules/plugin_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import List, Optional

from tortoise import fields
from tortoise.models import Model
Expand Down Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions src/modules/ticket_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import List, Optional

from tortoise import fields
from tortoise.models import Model
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/modules/user_info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import random
from datetime import date
from typing import Dict

from tortoise import fields
from tortoise.models import Model
Expand Down Expand Up @@ -45,7 +46,7 @@ async def sign_in(cls,
friendly_add: int,
gold_base: int,
lucky_gold: int
) -> dict[str, int]:
) -> Dict[str, int]:
'''
:说明
设置签到
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/jx3_search/data_source.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/jx3_search/model.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/weather/_weather.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions src/utils/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import Union
from typing import Dict, Union

import yaml

Expand All @@ -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:
Expand Down

0 comments on commit 2c676bd

Please sign in to comment.