1
0
forked from bot/app
LiteyukiBot/docs/dev/api/bot/README.md

228 lines
2.8 KiB
Markdown
Raw Normal View History

2024-08-19 09:43:46 +08:00
---
title: liteyuki.bot
index: true
icon: laptop-code
category: API
---
### ***def*** `get_bot() -> LiteyukiBot`
获取轻雪实例
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Returns:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
LiteyukiBot: 当前的轻雪实例
### ***def*** `get_config(key: str, default: Any) -> Any`
获取配置
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
key: 配置键
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
default: 默认值
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Returns:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Any: 配置值
### ***def*** `get_config_with_compat(key: str, compat_keys: tuple[str], default: Any) -> Any`
获取配置,兼容旧版本
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
key: 配置键
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
compat_keys: 兼容键
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
default: 默认值
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Returns:
2024-08-19 09:55:47 +08:00
2024-08-19 09:43:46 +08:00
Any: 配置值
### ***def*** `print_logo() -> None`
2024-08-19 09:55:47 +08:00
### ***class*** `LiteyukiBot`
2024-08-19 09:43:46 +08:00
###   ***def*** `__init__(self) -> None`
 初始化轻雪实例
Args:
*args:
**kwargs: 配置
###   ***def*** `run(self) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 启动逻辑
2024-08-19 09:43:46 +08:00
###   ***def*** `keep_alive(self) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 保持轻雪运行
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `restart(self, delay: int) -> None`
2024-08-19 09:55:47 +08:00
 重启轻雪本体
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `restart_process(self, name: Optional[str]) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 停止轻雪
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
Args:
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
name: 进程名称, 默认为None, 所有进程
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `init(self) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 初始化轻雪, 自动调用
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `init_logger(self) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 
2024-08-19 09:43:46 +08:00
###   ***def*** `stop(self) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 停止轻雪
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `on_before_start(self, func: LIFESPAN_FUNC) -> None`
2024-08-19 09:55:47 +08:00
 注册启动前的函数
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
func:
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `on_after_start(self, func: LIFESPAN_FUNC) -> None`
2024-08-19 09:55:47 +08:00
 注册启动后的函数
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
func:
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `on_after_shutdown(self, func: LIFESPAN_FUNC) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 注册停止后的函数:未实现
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
Args:
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
func:
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `on_before_process_shutdown(self, func: LIFESPAN_FUNC) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 注册进程停止前的函数,为子进程停止时调用
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
func:
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `on_before_process_restart(self, func: LIFESPAN_FUNC) -> None`
2024-08-19 09:43:46 +08:00
2024-08-19 09:55:47 +08:00
 注册进程重启前的函数,为子进程重启时调用
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
func:
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `on_after_restart(self, func: LIFESPAN_FUNC) -> None`
2024-08-19 09:55:47 +08:00
 注册重启后的函数:未实现
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
func:
2024-08-19 09:43:46 +08:00
Returns:
###   ***def*** `on_after_nonebot_init(self, func: LIFESPAN_FUNC) -> None`
2024-08-19 09:55:47 +08:00
 注册nonebot初始化后的函数
2024-08-19 09:43:46 +08:00
Args:
2024-08-19 09:55:47 +08:00
func:
2024-08-19 09:43:46 +08:00
Returns:
### ***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'`