mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 08:39:59 +08:00
update code
This commit is contained in:
@@ -2,10 +2,13 @@ from typing import Optional
|
||||
from .group_manager import GroupManager
|
||||
from pathlib import Path
|
||||
from .data_source import init
|
||||
from .data_class import StaticData
|
||||
|
||||
# 群权限
|
||||
# 群管理
|
||||
group_manager: Optional[GroupManager] = GroupManager(
|
||||
Path() / "data" / "manager" / "group_manager.json"
|
||||
)
|
||||
|
||||
withdraw_message_id_manager: Optional[StaticData] = StaticData(None)
|
||||
|
||||
init(group_manager)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Union
|
||||
from typing import Union, Optional
|
||||
from pathlib import Path
|
||||
import ujson as json
|
||||
|
||||
@@ -8,12 +8,13 @@ class StaticData:
|
||||
静态数据共享类
|
||||
"""
|
||||
|
||||
def __init__(self, file: Path):
|
||||
file.parent.mkdir(exist_ok=True, parents=True)
|
||||
self.file = file
|
||||
def __init__(self, file: Optional[Path]):
|
||||
self.data = {}
|
||||
if file.exists():
|
||||
self.data: dict = json.load(open(file, "r", encoding="utf8"))
|
||||
if file:
|
||||
file.parent.mkdir(exist_ok=True, parents=True)
|
||||
self.file = file
|
||||
if file.exists():
|
||||
self.data: dict = json.load(open(file, "r", encoding="utf8"))
|
||||
|
||||
def set(self, key, value):
|
||||
self.data[key] = value
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Optional
|
||||
from configs.config import DEFAULT_GROUP_LEVEL
|
||||
from typing import Optional, List
|
||||
from pathlib import Path
|
||||
from .data_class import StaticData
|
||||
|
||||
@@ -132,6 +133,13 @@ class GroupManager(StaticData):
|
||||
if group_id in self.data['super']['white_group_list']:
|
||||
self.data['super']['white_group_list'].remove(group_id)
|
||||
|
||||
def get_group_white_list(self) -> List[str]:
|
||||
"""
|
||||
说明:
|
||||
获取所有群白名单
|
||||
"""
|
||||
return self.data['super']['white_group_list']
|
||||
|
||||
def _set_plugin_status(
|
||||
self,
|
||||
plugin_cmd: str,
|
||||
@@ -183,4 +191,6 @@ class GroupManager(StaticData):
|
||||
参数:
|
||||
:param group_id: 群号
|
||||
"""
|
||||
self.data["group_manager"][group_id] = {"level": 5, "close_plugins": []}
|
||||
self.data["group_manager"][group_id] = {"level": DEFAULT_GROUP_LEVEL, "close_plugins": []}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user