From 1d0b18291ec3dec10f39813f5212f206205fa7cd Mon Sep 17 00:00:00 2001 From: snowy Date: Sun, 18 Aug 2024 05:10:57 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E8=80=85=E6=A8=A1=E5=BC=8F=EF=BC=8C=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + liteyuki/dev/plugin.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 liteyuki/dev/plugin.py diff --git a/.gitignore b/.gitignore index b2c00f66..1ab3337e 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ prompt.txt # pdm .pdm-python +.pdm-build dist \ No newline at end of file diff --git a/liteyuki/dev/plugin.py b/liteyuki/dev/plugin.py new file mode 100644 index 00000000..ad5507a9 --- /dev/null +++ b/liteyuki/dev/plugin.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +""" +Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved + +@Time : 2024/8/18 上午5:04 +@Author : snowykami +@Email : snowykami@outlook.com +@File : plugin.py +@Software: PyCharm +""" +from pathlib import Path + +from liteyuki.bot import LiteyukiBot +from liteyuki.config import load_config_in_default + + +def run_plugins(*module_path: str | Path): + """ + 运行插件,无需手动初始化bot + Args: + module_path: 插件路径,参考`liteyuki.load_plugin`的函数签名 + """ + cfg = load_config_in_default() + cfg["liteyuki.plugins"] = cfg.get("liteyuki.plugins", []).extend(module_path) + bot = LiteyukiBot(cfg) + bot.run()