app/docs/dev/api/bot/README.md

186 lines
2.4 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
2024-08-19 09:55:47 +08:00
###   ***def*** `run(self: Any) -> 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
###   ***def*** `keep_alive(self: Any) -> 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:
2024-08-19 09:55:47 +08:00
###   ***def*** `restart(self: Any, delay: int) -> None`
 重启轻雪本体
2024-08-19 09:43:46 +08:00
Returns:
2024-08-19 09:55:47 +08:00
###   ***def*** `restart_process(self: Any, 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:
2024-08-19 09:55:47 +08:00
###   ***def*** `init(self: Any) -> 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:
2024-08-19 09:55:47 +08:00
###   ***def*** `init_logger(self: Any) -> 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
###   ***def*** `stop(self: Any) -> 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:
2024-08-19 09:55:47 +08:00
###   ***def*** `on_before_start(self: Any, func: LIFESPAN_FUNC) -> None`
 注册启动前的函数
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:
2024-08-19 09:55:47 +08:00
###   ***def*** `on_after_start(self: Any, func: LIFESPAN_FUNC) -> None`
 注册启动后的函数
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:
2024-08-19 09:55:47 +08:00
###   ***def*** `on_after_shutdown(self: Any, 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:
2024-08-19 09:55:47 +08:00
###   ***def*** `on_before_process_shutdown(self: Any, 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:
2024-08-19 09:55:47 +08:00
###   ***def*** `on_before_process_restart(self: Any, 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:
2024-08-19 09:55:47 +08:00
###   ***def*** `on_after_restart(self: Any, func: LIFESPAN_FUNC) -> None`
 注册重启后的函数:未实现
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:
2024-08-19 09:55:47 +08:00
###   ***def*** `on_after_nonebot_init(self: Any, func: LIFESPAN_FUNC) -> None`
 注册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: