aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--HydroRoll/__init__.py24
2 files changed, 16 insertions, 10 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 29c8b07..27884ec 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
-name = "__force"
+name = "HydrRoll"
crate-type = ["cdylib"]
[dependencies]
diff --git a/HydroRoll/__init__.py b/HydroRoll/__init__.py
index 7f21b80..cfaff13 100644
--- a/HydroRoll/__init__.py
+++ b/HydroRoll/__init__.py
@@ -1,4 +1,5 @@
"""中间件"""
+
from ast import literal_eval
import os
from os.path import dirname, join, abspath
@@ -8,11 +9,16 @@ from .config import Directory
from .models.utils import *
import joblib
+try:
+ from .HydroRoll import sum_as_string
+except ImportError:
+ ...
+
BASE_DIR = Directory(_path=dirname(abspath("__file__")))
HYDRO_DIR = dirname(abspath(__file__))
-def _init_directory(_prefix: str = ''):
+def _init_directory(_prefix: str = ""):
"""初始化水系目录"""
for _ in BASE_DIR.get_dice_dir_list(_prefix):
if not os.path.exists(_):
@@ -21,8 +27,7 @@ def _init_directory(_prefix: str = ''):
def _load_models():
models = {}
- models['hola'] = joblib.load(
- join(HYDRO_DIR, 'models', 'hola.pkl'))
+ models["hola"] = joblib.load(join(HYDRO_DIR, "models", "hola.pkl"))
return models
@@ -31,19 +36,20 @@ def load_model(model):
return _load_models()[model]
-def init_directory(_prefix: str = 'HydroRoll'):
+def init_directory(_prefix: str = "HydroRoll"):
_init_directory(_prefix=_prefix)
class HydroRoll(Plugin):
"""中间件"""
+
class Config(ConfigModel):
__config_name__ = "HydroRoll"
priority = 0
# TODO: infini should be able to handle all signals and tokens from Psi.
- logger.info("Loading infini...")
+ logger.info(f"Loading infini... with {sum_as_string(2,3)}")
async def handle(self) -> None:
"""
@@ -66,9 +72,9 @@ class HydroRoll(Plugin):
@BODY: lexer module will return a list of tokens, parser module will parse the tokens into a tree, and executor module will execute the tokens with a stack with a bool return value.
"""
logger.info("loading psi...")
- if not self.bot.global_state.get('HydroRoll.dir'):
- hola = load_model('hola')
+ if not self.bot.global_state.get("HydroRoll.dir"):
+ hola = load_model("hola")
init_directory()
- self.bot.global_state['HydroRoll.dir'] = True
- return self.event.adapter.name in ['cqhttp', 'kook', 'console', 'mirai']
+ self.bot.global_state["HydroRoll.dir"] = True
+ return self.event.adapter.name in ["cqhttp", "kook", "console", "mirai"]