mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-06 04:10:02 +08:00
优化管理员帮助,超级用户帮助图片,重新移植gamedraw,修复pil帮助私聊时无法生成
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
from typing import Union, Optional, TypeVar, Generic, Dict, NoReturn, Any
|
||||
from pathlib import Path
|
||||
from ruamel.yaml import YAML
|
||||
from ruamel import yaml
|
||||
import ujson as json
|
||||
import copy
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Generic, NoReturn, Optional, TypeVar, Union
|
||||
|
||||
import ujson as json
|
||||
from ruamel import yaml
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
from .models import *
|
||||
|
||||
_yaml = YAML(typ="safe")
|
||||
|
||||
|
||||
T = TypeVar("T", AdminSetting, BaseData, PluginBlock, PluginCd, PluginCount, PluginSetting, Plugin)
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class StaticData(Generic[T]):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import copy
|
||||
from typing import List, Union, Dict, Callable
|
||||
from typing import List, Union, Dict, Callable, Any
|
||||
from pathlib import Path
|
||||
from .models import BaseData, BaseGroup
|
||||
from utils.manager.data_class import StaticData
|
||||
@@ -57,7 +57,7 @@ def init_task(func: Callable):
|
||||
return wrapper
|
||||
|
||||
|
||||
class GroupManager(StaticData):
|
||||
class GroupManager(StaticData[BaseData]):
|
||||
"""
|
||||
群权限 | 功能 | 总开关 | 聊天时间 管理器
|
||||
"""
|
||||
@@ -354,6 +354,9 @@ class GroupManager(StaticData):
|
||||
with open(path, "w", encoding="utf8") as f:
|
||||
json.dump(dict_data, f, ensure_ascii=False, indent=4)
|
||||
|
||||
def get(self, key: str, default: Any = None) -> BaseGroup:
|
||||
return self._data.group_manager.get(key, default)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self._data.group_manager[key] = value
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ class PluginData(BaseModel):
|
||||
name: str
|
||||
plugin_type: PluginType # 插件内部类型,根据name [Hidden] [Admin] [SUPERUSER]
|
||||
usage: Optional[str]
|
||||
superuser_usage: Optional[str]
|
||||
des: Optional[str]
|
||||
task: Optional[Dict[str, str]]
|
||||
menu_type: Tuple[Union[str, int], ...] = ("normal",) # 菜单类型
|
||||
|
||||
@@ -4,7 +4,7 @@ from . import StaticData
|
||||
from .models import PluginData
|
||||
|
||||
|
||||
class PluginDataManager(StaticData):
|
||||
class PluginDataManager(StaticData[PluginData]):
|
||||
"""
|
||||
插件所有信息管理
|
||||
"""
|
||||
|
||||
@@ -9,7 +9,7 @@ from .models import PluginBlock
|
||||
_yaml = yaml.YAML(typ="safe")
|
||||
|
||||
|
||||
class Plugins2blockManager(StaticData):
|
||||
class Plugins2blockManager(StaticData[PluginBlock]):
|
||||
"""
|
||||
插件命令阻塞 管理器
|
||||
"""
|
||||
|
||||
@@ -9,7 +9,7 @@ from .models import PluginCd
|
||||
_yaml = yaml.YAML(typ="safe")
|
||||
|
||||
|
||||
class Plugins2cdManager(StaticData):
|
||||
class Plugins2cdManager(StaticData[PluginCd]):
|
||||
"""
|
||||
插件命令 cd 管理器
|
||||
"""
|
||||
|
||||
@@ -9,7 +9,7 @@ from .models import PluginCount
|
||||
_yaml = yaml.YAML(typ="safe")
|
||||
|
||||
|
||||
class Plugins2countManager(StaticData):
|
||||
class Plugins2countManager(StaticData[PluginCount]):
|
||||
"""
|
||||
插件命令 次数 管理器
|
||||
"""
|
||||
|
||||
@@ -7,7 +7,7 @@ from .models import PluginSetting, PluginType
|
||||
_yaml = yaml.YAML(typ="safe")
|
||||
|
||||
|
||||
class Plugins2settingsManager(StaticData):
|
||||
class Plugins2settingsManager(StaticData[PluginSetting]):
|
||||
"""
|
||||
插件命令阻塞 管理器
|
||||
"""
|
||||
|
||||
@@ -30,7 +30,7 @@ def init_plugin(func: Callable):
|
||||
return wrapper
|
||||
|
||||
|
||||
class PluginsManager(StaticData):
|
||||
class PluginsManager(StaticData[Plugin]):
|
||||
"""
|
||||
插件 管理器
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user