新增开发者模式,快速运行插件

This commit is contained in:
远野千束 2024-08-18 05:10:57 +08:00
parent 16df5706ff
commit 1d0b18291e
2 changed files with 27 additions and 0 deletions

1
.gitignore vendored
View File

@ -48,4 +48,5 @@ prompt.txt
# pdm
.pdm-python
.pdm-build
dist

26
liteyuki/dev/plugin.py Normal file
View File

@ -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()