summaryrefslogtreecommitdiffstatshomepage
path: root/src/hydrorollcore
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2023-10-07 03:40:55 +0800
committer简律纯 <i@jyunko.cn>2023-10-07 03:40:55 +0800
commiteba74ab903dadf43acefbd145a501e83f56d104f (patch)
tree3a4bbd98adaf923aaa793fd53ef032421ce346cb /src/hydrorollcore
parent956e7e7e98778993131fe5c03578ae46800dd2a3 (diff)
downloadinfini-eba74ab903dadf43acefbd145a501e83f56d104f.tar.gz
infini-eba74ab903dadf43acefbd145a501e83f56d104f.zip
fix(cli): new commandv0.1.1
Diffstat (limited to 'src/hydrorollcore')
-rw-r--r--src/hydrorollcore/__init__.py10
-rw-r--r--src/hydrorollcore/cli.py7
-rw-r--r--src/hydrorollcore/rule.py17
3 files changed, 16 insertions, 18 deletions
diff --git a/src/hydrorollcore/__init__.py b/src/hydrorollcore/__init__.py
index 48f904b0..48fa8a09 100644
--- a/src/hydrorollcore/__init__.py
+++ b/src/hydrorollcore/__init__.py
@@ -1,7 +1,7 @@
-name = "HydroRollCore"
-
-from HydroRollCore.core import Core
-from HydroRollCore.rule import Rule, RuleLoadType
+from HydroRollCore.cli import Cli
from HydroRollCore.config import ConfigModel
+from HydroRollCore.rule import Rule, RuleLoadType
+from HydroRollCore.core import Core
+__version__ = "0.1.1"
-__all__ = ['Core', 'Rule', 'ConfigModel', 'RuleLoadType'] \ No newline at end of file
+__all__ = ['Core', 'Rule', 'ConfigModel', 'RuleLoadType', 'Cli']
diff --git a/src/hydrorollcore/cli.py b/src/hydrorollcore/cli.py
index 548f5925..d9d34ef2 100644
--- a/src/hydrorollcore/cli.py
+++ b/src/hydrorollcore/cli.py
@@ -1,7 +1,7 @@
import argparse
from tkinter import messagebox
-class Cli(object):
+class Cli:
def parse_args():
# 创建解析器对象
parser = argparse.ArgumentParser(description='HydroRoll 命令行工具')
@@ -18,7 +18,4 @@ class Cli(object):
messagebox.showinfo('提示', '这是一个弹窗!')
if args.path:
- print('输入的路径:', args.path)
-
- if __name__ == '__main__':
- main()
+ print('输入的路径:', args.path) \ No newline at end of file
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):