mirror of
				https://github.com/LiteyukiStudio/LiteyukiBot.git
				synced 2025-10-31 09:06:24 +00:00 
			
		
		
		
	⚡ 添加进程及生命周期管理器,添加轻雪框架支持
This commit is contained in:
		| @@ -2,6 +2,10 @@ from liteyuki.bot import ( | |||||||
|     LiteyukiBot, |     LiteyukiBot, | ||||||
|     get_bot |     get_bot | ||||||
| ) | ) | ||||||
|  | from liteyuki.plugin import ( | ||||||
|  |     load_plugin, | ||||||
|  |     load_plugins | ||||||
|  | ) | ||||||
|  |  | ||||||
| # def get_bot_instance() -> LiteyukiBot | None: | # def get_bot_instance() -> LiteyukiBot | None: | ||||||
| #     """ | #     """ | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ from typing import Any, Coroutine, Optional | |||||||
|  |  | ||||||
| import nonebot | import nonebot | ||||||
|  |  | ||||||
|  | import liteyuki | ||||||
| from liteyuki.plugin.load import load_plugin, load_plugins | from liteyuki.plugin.load import load_plugin, load_plugins | ||||||
| from src.utils import ( | from src.utils import ( | ||||||
|     adapter_manager, |     adapter_manager, | ||||||
| @@ -50,7 +51,6 @@ $$$$$$$$/ $$$$$$/    $$/    $$$$$$$$/     $$/      $$$$$$/  $$/   $$/ $$$$$$/ | |||||||
|             """ + "\033[0m") |             """ + "\033[0m") | ||||||
|  |  | ||||||
|     def run(self, *args, **kwargs): |     def run(self, *args, **kwargs): | ||||||
|  |  | ||||||
|         if _MAIN_PROCESS: |         if _MAIN_PROCESS: | ||||||
|             load_plugins("liteyuki/plugins") |             load_plugins("liteyuki/plugins") | ||||||
|             asyncio.run(self.lifespan.before_start()) |             asyncio.run(self.lifespan.before_start()) | ||||||
| @@ -177,9 +177,6 @@ $$$$$$$$/ $$$$$$/    $$/    $$$$$$$$/     $$/      $$$$$$/  $$/   $$/ $$$$$$/ | |||||||
|     def init_config(self): |     def init_config(self): | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     def register_adapters(self, *args): |  | ||||||
|         pass |  | ||||||
|  |  | ||||||
|     def on_before_start(self, func: LIFESPAN_FUNC): |     def on_before_start(self, func: LIFESPAN_FUNC): | ||||||
|         """ |         """ | ||||||
|         注册启动前的函数 |         注册启动前的函数 | ||||||
|   | |||||||
| @@ -1,10 +1,11 @@ | |||||||
| from liteyuki.plugin.model import Plugin, PluginMetadata | from liteyuki.plugin.model import Plugin, PluginMetadata | ||||||
| from liteyuki.plugin.load import load_plugin, _plugins | from liteyuki.plugin.load import load_plugin, load_plugins, _plugins | ||||||
|  |  | ||||||
| __all__ = [ | __all__ = [ | ||||||
|         "PluginMetadata", |         "PluginMetadata", | ||||||
|         "Plugin", |         "Plugin", | ||||||
|         "load_plugin", |         "load_plugin", | ||||||
|  |         "load_plugins", | ||||||
| ] | ] | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,6 +22,11 @@ from liteyuki.utils import path_to_module_name | |||||||
|  |  | ||||||
| _plugins: dict[str, Plugin] = {} | _plugins: dict[str, Plugin] = {} | ||||||
|  |  | ||||||
|  | __all__ = [ | ||||||
|  |     "load_plugin", | ||||||
|  |     "load_plugins", | ||||||
|  | ] | ||||||
|  |  | ||||||
|  |  | ||||||
| def load_plugin(module_path: str | Path) -> Optional[Plugin]: | def load_plugin(module_path: str | Path) -> Optional[Plugin]: | ||||||
|     """加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。 |     """加载单个插件,可以是本地插件或是通过 `pip` 安装的插件。 | ||||||
|   | |||||||
| @@ -1,9 +1,6 @@ | |||||||
| import multiprocessing | import multiprocessing | ||||||
| import time | import time | ||||||
|  |  | ||||||
| import nonebot |  | ||||||
| from nonebot import get_driver |  | ||||||
|  |  | ||||||
| from liteyuki.plugin import PluginMetadata | from liteyuki.plugin import PluginMetadata | ||||||
| from liteyuki import get_bot | from liteyuki import get_bot | ||||||
|  |  | ||||||
| @@ -11,12 +8,11 @@ __plugin_metadata__ = PluginMetadata( | |||||||
|     name="plugin_loader", |     name="plugin_loader", | ||||||
|     description="轻雪插件加载器", |     description="轻雪插件加载器", | ||||||
|     usage="", |     usage="", | ||||||
|     type="", |     type="liteyuki-main", | ||||||
|     homepage="" |     homepage="" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| from src.utils import TempConfig, common_db | from src.utils import TempConfig, common_db | ||||||
|  |  | ||||||
| liteyuki = get_bot() | liteyuki = get_bot() | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -38,4 +34,3 @@ def _(): | |||||||
| @liteyuki.on_after_nonebot_init | @liteyuki.on_after_nonebot_init | ||||||
| async def _(): | async def _(): | ||||||
|     print("NoneBot初始化完成") |     print("NoneBot初始化完成") | ||||||
|     nonebot.load_plugin("src.liteyuki_main") |  | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								liteyuki/plugins/what_litaco/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								liteyuki/plugins/what_litaco/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | # -*- coding: utf-8 -*- | ||||||
|  | """ | ||||||
|  | Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved  | ||||||
|  |  | ||||||
|  | @Time    : 2024/7/25 上午2:28 | ||||||
|  | @Author  : snowykami | ||||||
|  | @Email   : snowykami@outlook.com | ||||||
|  | @File    : __init__.py | ||||||
|  | @Software: PyCharm | ||||||
|  | """ | ||||||
		Reference in New Issue
	
	Block a user