From eba74ab903dadf43acefbd145a501e83f56d104f Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Sat, 7 Oct 2023 03:40:55 +0800 Subject: fix(cli): new command --- src/hydrorollcore/rule.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/hydrorollcore/rule.py') diff --git a/src/hydrorollcore/rule.py b/src/hydrorollcore/rule.py index 54eaf48e..e48b6ce2 100644 --- a/src/hydrorollcore/rule.py +++ b/src/hydrorollcore/rule.py @@ -1,14 +1,16 @@ from abc import ABC, abstractmethod -import os, os.path +import os +import os.path from enum import Enum from iamai.config import ConfigModel from iamai.utils import is_config_class from typing import Generic, NoReturn, Optional, Type, TYPE_CHECKING -from HydroRoll.typing import T_Event, T_Config + if TYPE_CHECKING: from iamai.bot import Bot + class RuleLoadType(Enum): """插件加载类型。""" @@ -16,9 +18,9 @@ class RuleLoadType(Enum): NAME = "name" FILE = "file" CLASS = "class" - -class Rule(ABC, Generic[T_Event, T_Config]): + +class Rule(ABC): """所有 iamai 插件的基类。 Attributes: @@ -30,14 +32,13 @@ class Rule(ABC, Generic[T_Event, T_Config]): 否则为定义插件在的 Python 模块的位置。 """ - event: T_Event priority: int = 0 Config: Type[ConfigModel] __rule_load_type__: RuleLoadType __rule_file_path__: Optional[str] - def __init__(self, event: T_Event): + def __init__(self, event): self.event = event if not hasattr(self, "priority"): @@ -60,9 +61,9 @@ class Rule(ABC, Generic[T_Event, T_Config]): def bot(self) -> "Bot": """机器人对象。""" return self.event.adapter.bot - + @property - def config(self) -> Optional[T_Config]: + def config(self): """规则包配置。""" config_class: ConfigModel = getattr(self, "Rule", None) if is_config_class(config_class): -- cgit v1.2.3-70-g09d2