diff options
| author | 2023-10-07 03:40:55 +0800 | |
|---|---|---|
| committer | 2023-10-07 03:40:55 +0800 | |
| commit | eba74ab903dadf43acefbd145a501e83f56d104f (patch) | |
| tree | 3a4bbd98adaf923aaa793fd53ef032421ce346cb /src/hydrorollcore/rule.py | |
| parent | 956e7e7e98778993131fe5c03578ae46800dd2a3 (diff) | |
| download | infini-0.1.1.tar.gz infini-0.1.1.zip | |
fix(cli): new commandv0.1.1
Diffstat (limited to 'src/hydrorollcore/rule.py')
| -rw-r--r-- | src/hydrorollcore/rule.py | 17 |
1 files changed, 9 insertions, 8 deletions
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): |
