⬇️ 更新文档样式
This commit is contained in:
@ -1,22 +1,18 @@
|
||||
---
|
||||
title: liteyuki.bot
|
||||
index: true
|
||||
icon: laptop-code
|
||||
category: API
|
||||
---
|
||||
|
||||
### ***def*** `get_bot() -> LiteyukiBot`
|
||||
|
||||
获取轻雪实例
|
||||
### *func* `get_bot() -> LiteyukiBot`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 获取轻雪实例
|
||||
|
||||
|
||||
**返回**: LiteyukiBot: 当前的轻雪实例
|
||||
|
||||
LiteyukiBot: 当前的轻雪实例
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def get_bot() -> LiteyukiBot:
|
||||
@ -35,24 +31,21 @@ def get_bot() -> LiteyukiBot:
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***def*** `get_config(key: str, default: Any) -> Any`
|
||||
|
||||
获取配置
|
||||
|
||||
Args:
|
||||
|
||||
key: 配置键
|
||||
|
||||
default: 默认值
|
||||
### *func* `get_config(key: str = None) -> Any`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 获取配置
|
||||
|
||||
**参数**:
|
||||
> - key: 配置键
|
||||
> - default: 默认值
|
||||
|
||||
**返回**: Any: 配置值
|
||||
|
||||
Any: 配置值
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def get_config(key: str, default: Any=None) -> Any:
|
||||
@ -69,26 +62,22 @@ def get_config(key: str, default: Any=None) -> Any:
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***def*** `get_config_with_compat(key: str, compat_keys: tuple[str], default: Any) -> Any`
|
||||
|
||||
获取配置,兼容旧版本
|
||||
|
||||
Args:
|
||||
|
||||
key: 配置键
|
||||
|
||||
compat_keys: 兼容键
|
||||
|
||||
default: 默认值
|
||||
### *func* `get_config_with_compat(key: str = None) -> Any`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 获取配置,兼容旧版本
|
||||
|
||||
**参数**:
|
||||
> - key: 配置键
|
||||
> - compat_keys: 兼容键
|
||||
> - default: 默认值
|
||||
|
||||
**返回**: Any: 配置值
|
||||
|
||||
Any: 配置值
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def get_config_with_compat(key: str, compat_keys: tuple[str], default: Any=None) -> Any:
|
||||
@ -112,12 +101,11 @@ def get_config_with_compat(key: str, compat_keys: tuple[str], default: Any=None)
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***def*** `print_logo() -> None`
|
||||
|
||||
### *func* `print_logo()`
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def print_logo():
|
||||
@ -125,22 +113,20 @@ def print_logo():
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***class*** `LiteyukiBot`
|
||||
### **class** `LiteyukiBot`
|
||||
### *method* `__init__(self) -> None`
|
||||
|
||||
|
||||
|
||||
###   ***def*** `__init__(self) -> None`
|
||||
**说明**: 初始化轻雪实例
|
||||
|
||||
 初始化轻雪实例
|
||||
**参数**:
|
||||
> - *args:
|
||||
> - **kwargs: 配置
|
||||
|
||||
Args:
|
||||
|
||||
*args:
|
||||
|
||||
**kwargs: 配置
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
@ -177,12 +163,15 @@ def __init__(self, *args, **kwargs) -> None:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `run(self) -> None`
|
||||
### *method* `run(self)`
|
||||
|
||||
|
||||
|
||||
**说明**: 启动逻辑
|
||||
|
||||
 启动逻辑
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def run(self):
|
||||
@ -196,14 +185,15 @@ def run(self):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `keep_alive(self) -> None`
|
||||
### *method* `keep_alive(self)`
|
||||
|
||||
 保持轻雪运行
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 保持轻雪运行
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def keep_alive(self):
|
||||
@ -221,14 +211,46 @@ def keep_alive(self):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `restart(self, delay: int) -> None`
|
||||
### *method* `_handle_exit(self, signum, frame)`
|
||||
|
||||
 重启轻雪本体
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 信号处理
|
||||
|
||||
**参数**:
|
||||
> - signum:
|
||||
> - frame:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def _handle_exit(self, signum, frame):
|
||||
"""
|
||||
信号处理
|
||||
Args:
|
||||
signum:
|
||||
frame:
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
logger.info('Received signal, stopping all processes.')
|
||||
self.stop()
|
||||
sys.exit(0)
|
||||
```
|
||||
</details>
|
||||
|
||||
### *method* `restart(self, delay: int = 0)`
|
||||
|
||||
|
||||
|
||||
**说明**: 重启轻雪本体
|
||||
|
||||
|
||||
<details>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def restart(self, delay: int=0):
|
||||
@ -257,18 +279,18 @@ def restart(self, delay: int=0):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `restart_process(self, name: Optional[str]) -> None`
|
||||
### *method* `restart_process(self, name: Optional[str] = None)`
|
||||
|
||||
 停止轻雪
|
||||
|
||||
Args:
|
||||
|
||||
name: 进程名称, 默认为None, 所有进程
|
||||
**说明**: 停止轻雪
|
||||
|
||||
**参数**:
|
||||
> - name: 进程名称, 默认为None, 所有进程
|
||||
|
||||
Returns:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def restart_process(self, name: Optional[str]=None):
|
||||
@ -290,14 +312,15 @@ def restart_process(self, name: Optional[str]=None):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `init(self) -> None`
|
||||
### *method* `init(self)`
|
||||
|
||||
 初始化轻雪, 自动调用
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 初始化轻雪, 自动调用
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def init(self, *args, **kwargs):
|
||||
@ -310,12 +333,11 @@ def init(self, *args, **kwargs):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `init_logger(self) -> None`
|
||||
### *method* `init_logger(self)`
|
||||
|
||||
 
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def init_logger(self):
|
||||
@ -323,14 +345,15 @@ def init_logger(self):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `stop(self) -> None`
|
||||
### *method* `stop(self)`
|
||||
|
||||
 停止轻雪
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 停止轻雪
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def stop(self):
|
||||
@ -344,20 +367,18 @@ def stop(self):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_before_start(self, func: LIFESPAN_FUNC) -> None`
|
||||
|
||||
 注册启动前的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_before_start(self, func: LIFESPAN_FUNC)`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册启动前的函数
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_before_start(self, func: LIFESPAN_FUNC):
|
||||
@ -373,20 +394,18 @@ def on_before_start(self, func: LIFESPAN_FUNC):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_after_start(self, func: LIFESPAN_FUNC) -> None`
|
||||
|
||||
 注册启动后的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_after_start(self, func: LIFESPAN_FUNC)`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册启动后的函数
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_after_start(self, func: LIFESPAN_FUNC):
|
||||
@ -402,20 +421,18 @@ def on_after_start(self, func: LIFESPAN_FUNC):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_after_shutdown(self, func: LIFESPAN_FUNC) -> None`
|
||||
|
||||
 注册停止后的函数:未实现
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_after_shutdown(self, func: LIFESPAN_FUNC)`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册停止后的函数:未实现
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_after_shutdown(self, func: LIFESPAN_FUNC):
|
||||
@ -431,20 +448,18 @@ def on_after_shutdown(self, func: LIFESPAN_FUNC):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_before_process_shutdown(self, func: LIFESPAN_FUNC) -> None`
|
||||
|
||||
 注册进程停止前的函数,为子进程停止时调用
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_before_process_shutdown(self, func: LIFESPAN_FUNC)`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册进程停止前的函数,为子进程停止时调用
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_before_process_shutdown(self, func: LIFESPAN_FUNC):
|
||||
@ -460,20 +475,18 @@ def on_before_process_shutdown(self, func: LIFESPAN_FUNC):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_before_process_restart(self, func: LIFESPAN_FUNC) -> None`
|
||||
|
||||
 注册进程重启前的函数,为子进程重启时调用
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_before_process_restart(self, func: LIFESPAN_FUNC)`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册进程重启前的函数,为子进程重启时调用
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_before_process_restart(self, func: LIFESPAN_FUNC):
|
||||
@ -489,20 +502,18 @@ def on_before_process_restart(self, func: LIFESPAN_FUNC):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_after_restart(self, func: LIFESPAN_FUNC) -> None`
|
||||
|
||||
 注册重启后的函数:未实现
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_after_restart(self, func: LIFESPAN_FUNC)`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册重启后的函数:未实现
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_after_restart(self, func: LIFESPAN_FUNC):
|
||||
@ -518,20 +529,18 @@ def on_after_restart(self, func: LIFESPAN_FUNC):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_after_nonebot_init(self, func: LIFESPAN_FUNC) -> None`
|
||||
|
||||
 注册nonebot初始化后的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_after_nonebot_init(self, func: LIFESPAN_FUNC)`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册nonebot初始化后的函数
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_after_nonebot_init(self, func: LIFESPAN_FUNC):
|
||||
@ -547,35 +556,7 @@ def on_after_nonebot_init(self, func: LIFESPAN_FUNC):
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***var*** `executable = sys.executable`
|
||||
|
||||
|
||||
|
||||
### ***var*** `args = sys.argv`
|
||||
|
||||
|
||||
|
||||
### ***var*** `chan_active = get_channel(f'{name}-active')`
|
||||
|
||||
|
||||
|
||||
### ***var*** `cmd = 'start'`
|
||||
|
||||
|
||||
|
||||
### ***var*** `chan_active = get_channel(f'{process_name}-active')`
|
||||
|
||||
|
||||
|
||||
### ***var*** `cmd = 'nohup'`
|
||||
|
||||
|
||||
|
||||
### ***var*** `cmd = 'open'`
|
||||
|
||||
|
||||
|
||||
### ***var*** `cmd = 'nohup'`
|
||||
|
||||
### ***var*** `_BOT_INSTANCE = NO_DEFAULT`
|
||||
|
||||
- **类型**: `LiteyukiBot`
|
||||
|
||||
|
@ -1,57 +1,16 @@
|
||||
---
|
||||
title: liteyuki.bot.lifespan
|
||||
order: 1
|
||||
icon: laptop-code
|
||||
category: API
|
||||
---
|
||||
### **class** `Lifespan`
|
||||
### *method* `__init__(self) -> None`
|
||||
|
||||
### ***def*** `run_funcs(funcs: list[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC]) -> None`
|
||||
|
||||
运行函数
|
||||
|
||||
Args:
|
||||
**说明**: 轻雪生命周期管理,启动、停止、重启
|
||||
|
||||
funcs:
|
||||
|
||||
Returns:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
|
||||
```python
|
||||
@staticmethod
|
||||
def run_funcs(funcs: list[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC], *args, **kwargs) -> None:
|
||||
"""
|
||||
运行函数
|
||||
Args:
|
||||
funcs:
|
||||
Returns:
|
||||
"""
|
||||
try:
|
||||
loop = asyncio.get_event_loop()
|
||||
except RuntimeError:
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
tasks = []
|
||||
for func in funcs:
|
||||
if is_coroutine_callable(func):
|
||||
tasks.append(func(*args, **kwargs))
|
||||
else:
|
||||
tasks.append(async_wrapper(func)(*args, **kwargs))
|
||||
loop.run_until_complete(asyncio.gather(*tasks))
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***class*** `Lifespan`
|
||||
|
||||
|
||||
|
||||
###   ***def*** `__init__(self) -> None`
|
||||
|
||||
 轻雪生命周期管理,启动、停止、重启
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def __init__(self) -> None:
|
||||
@ -69,19 +28,19 @@ def __init__(self) -> None:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***@staticmethod***
|
||||
###   ***def*** `run_funcs(funcs: list[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC]) -> None`
|
||||
### `@staticmethod`
|
||||
### *method* `run_funcs(funcs: list[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC]) -> None`
|
||||
|
||||
 运行函数
|
||||
|
||||
Args:
|
||||
|
||||
funcs:
|
||||
**说明**: 运行函数
|
||||
|
||||
**参数**:
|
||||
> - funcs:
|
||||
|
||||
Returns:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
@staticmethod
|
||||
@ -107,20 +66,20 @@ def run_funcs(funcs: list[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC], *args, **kwarg
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_before_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
### *method* `on_before_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
|
||||
 注册启动时的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
**说明**: 注册启动时的函数
|
||||
|
||||
Returns:
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
**返回**: LIFESPAN_FUNC:
|
||||
|
||||
LIFESPAN_FUNC:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_before_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
@ -136,20 +95,20 @@ def on_before_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_after_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
### *method* `on_after_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
|
||||
 注册启动时的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
**说明**: 注册启动时的函数
|
||||
|
||||
Returns:
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
**返回**: LIFESPAN_FUNC:
|
||||
|
||||
LIFESPAN_FUNC:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_after_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
@ -165,20 +124,20 @@ def on_after_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_before_process_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
### *method* `on_before_process_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
|
||||
 注册停止前的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
**说明**: 注册停止前的函数
|
||||
|
||||
Returns:
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
**返回**: LIFESPAN_FUNC:
|
||||
|
||||
LIFESPAN_FUNC:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_before_process_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
@ -194,22 +153,20 @@ def on_before_process_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_after_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
|
||||
 注册停止后的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_after_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册停止后的函数
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
**返回**: LIFESPAN_FUNC:
|
||||
|
||||
LIFESPAN_FUNC:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_after_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
@ -227,20 +184,20 @@ def on_after_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_before_process_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
### *method* `on_before_process_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
|
||||
 注册重启时的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
**说明**: 注册重启时的函数
|
||||
|
||||
Returns:
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
**返回**: LIFESPAN_FUNC:
|
||||
|
||||
LIFESPAN_FUNC:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_before_process_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
@ -256,20 +213,20 @@ def on_before_process_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_after_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
### *method* `on_after_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC`
|
||||
|
||||
 注册重启后的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
**说明**: 注册重启后的函数
|
||||
|
||||
Returns:
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
**返回**: LIFESPAN_FUNC:
|
||||
|
||||
LIFESPAN_FUNC:
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_after_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
@ -285,20 +242,18 @@ def on_after_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `on_after_nonebot_init(self, func: Any) -> None`
|
||||
|
||||
 注册 NoneBot 初始化后的函数
|
||||
|
||||
Args:
|
||||
|
||||
func:
|
||||
### *method* `on_after_nonebot_init(self, func)`
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
**说明**: 注册 NoneBot 初始化后的函数
|
||||
|
||||
**参数**:
|
||||
> - func:
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def on_after_nonebot_init(self, func):
|
||||
@ -315,14 +270,15 @@ def on_after_nonebot_init(self, func):
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `before_start(self) -> None`
|
||||
### *method* `before_start(self) -> None`
|
||||
|
||||
 启动前
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 启动前
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def before_start(self) -> None:
|
||||
@ -335,14 +291,15 @@ def before_start(self) -> None:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `after_start(self) -> None`
|
||||
### *method* `after_start(self) -> None`
|
||||
|
||||
 启动后
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 启动后
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def after_start(self) -> None:
|
||||
@ -355,14 +312,15 @@ def after_start(self) -> None:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `before_process_shutdown(self) -> None`
|
||||
### *method* `before_process_shutdown(self) -> None`
|
||||
|
||||
 停止前
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 停止前
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def before_process_shutdown(self) -> None:
|
||||
@ -375,14 +333,15 @@ def before_process_shutdown(self) -> None:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `after_shutdown(self) -> None`
|
||||
### *method* `after_shutdown(self) -> None`
|
||||
|
||||
 停止后
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 停止后
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def after_shutdown(self) -> None:
|
||||
@ -395,14 +354,15 @@ def after_shutdown(self) -> None:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `before_process_restart(self) -> None`
|
||||
### *method* `before_process_restart(self) -> None`
|
||||
|
||||
 重启前
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 重启前
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def before_process_restart(self) -> None:
|
||||
@ -415,14 +375,15 @@ def before_process_restart(self) -> None:
|
||||
```
|
||||
</details>
|
||||
|
||||
###   ***def*** `after_restart(self) -> None`
|
||||
### *method* `after_restart(self) -> None`
|
||||
|
||||
 重启后
|
||||
|
||||
Returns:
|
||||
|
||||
**说明**: 重启后
|
||||
|
||||
|
||||
<details>
|
||||
<summary>源代码</summary>
|
||||
<summary> <b>源代码</b> </summary>
|
||||
|
||||
```python
|
||||
def after_restart(self) -> None:
|
||||
@ -436,15 +397,27 @@ def after_restart(self) -> None:
|
||||
```
|
||||
</details>
|
||||
|
||||
### ***var*** `tasks = []`
|
||||
### ***var*** `SYNC_LIFESPAN_FUNC = Callable[[], Any]`
|
||||
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `ASYNC_LIFESPAN_FUNC = Callable[[], Awaitable[Any]]`
|
||||
|
||||
### ***var*** `loop = asyncio.get_event_loop()`
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `LIFESPAN_FUNC = SYNC_LIFESPAN_FUNC | ASYNC_LIFESPAN_FUNC`
|
||||
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `loop = asyncio.new_event_loop()`
|
||||
### ***var*** `SYNC_PROCESS_LIFESPAN_FUNC = Callable[[str], Any]`
|
||||
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `ASYNC_PROCESS_LIFESPAN_FUNC = Callable[[str], Awaitable[Any]]`
|
||||
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
### ***var*** `PROCESS_LIFESPAN_FUNC = SYNC_PROCESS_LIFESPAN_FUNC | ASYNC_PROCESS_LIFESPAN_FUNC`
|
||||
|
||||
- **类型**: `TypeAlias`
|
||||
|
||||
|
Reference in New Issue
Block a user