mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2025-07-27 22:40:55 +00:00
📝 生成了api文档
This commit is contained in:
@ -8,51 +8,37 @@ category: API
|
||||
### ***def*** `set_channel(name: str, channel: Channel) -> None`
|
||||
|
||||
设置通道实例
|
||||
|
||||
Args:
|
||||
|
||||
name: 通道名称
|
||||
|
||||
channel: 通道实例
|
||||
|
||||
### ***def*** `set_channels(channels: dict[str, Channel]) -> None`
|
||||
|
||||
设置通道实例
|
||||
|
||||
Args:
|
||||
|
||||
channels: 通道名称
|
||||
|
||||
### ***def*** `get_channel(name: str) -> Channel`
|
||||
|
||||
获取通道实例
|
||||
|
||||
Args:
|
||||
|
||||
name: 通道名称
|
||||
|
||||
Returns:
|
||||
|
||||
### ***def*** `get_channels() -> dict[str, Channel]`
|
||||
|
||||
获取通道实例
|
||||
|
||||
Returns:
|
||||
|
||||
### ***def*** `send(self: Any, data: T) -> None`
|
||||
|
||||
发送数据
|
||||
Args:
|
||||
data: 数据
|
||||
|
||||
### ***def*** `receive(self: Any) -> T`
|
||||
|
||||
接收数据
|
||||
Args:
|
||||
|
||||
### ***def*** `close(self: Any) -> None`
|
||||
|
||||
关闭通道
|
||||
|
||||
### ***def*** `on_receive(self: Any, filter_func: Optional[FILTER_FUNC]) -> Callable[[Callable[[T], Any]], Callable[[T], Any]]`
|
||||
|
||||
接收数据并执行函数
|
||||
Args:
|
||||
filter_func: 过滤函数,为None则不过滤
|
||||
Returns:
|
||||
装饰器,装饰一个函数在接收到数据后执行
|
||||
|
||||
### ***def*** `on_set_channel(data: tuple[str, dict[str, Any]]) -> None`
|
||||
|
||||
|
||||
@ -76,28 +62,36 @@ Returns:
|
||||
### ***class*** `Channel(Generic[T])`
|
||||
|
||||
通道类,可以在进程间和进程内通信,双向但同时只能有一个发送者和一个接收者
|
||||
|
||||
有两种接收工作方式,但是只能选择一种,主动接收和被动接收,主动接收使用 `receive` 方法,被动接收使用 `on_receive` 装饰器
|
||||
|
||||
####   ***def*** `send(self: Any, data: T) -> None`
|
||||
###   ***def*** `send(self: Any, data: T) -> None`
|
||||
|
||||
 发送数据
|
||||
|
||||
发送数据
|
||||
Args:
|
||||
|
||||
data: 数据
|
||||
|
||||
####   ***def*** `receive(self: Any) -> T`
|
||||
###   ***def*** `receive(self: Any) -> T`
|
||||
|
||||
 接收数据
|
||||
|
||||
接收数据
|
||||
Args:
|
||||
|
||||
####   ***def*** `close(self: Any) -> None`
|
||||
###   ***def*** `close(self: Any) -> None`
|
||||
|
||||
关闭通道
|
||||
 关闭通道
|
||||
|
||||
####   ***def*** `on_receive(self: Any, filter_func: Optional[FILTER_FUNC]) -> Callable[[Callable[[T], Any]], Callable[[T], Any]]`
|
||||
###   ***def*** `on_receive(self: Any, filter_func: Optional[FILTER_FUNC]) -> Callable[[Callable[[T], Any]], Callable[[T], Any]]`
|
||||
|
||||
 接收数据并执行函数
|
||||
|
||||
接收数据并执行函数
|
||||
Args:
|
||||
|
||||
filter_func: 过滤函数,为None则不过滤
|
||||
|
||||
Returns:
|
||||
|
||||
装饰器,装饰一个函数在接收到数据后执行
|
||||
|
||||
|
@ -5,42 +5,6 @@ icon: laptop-code
|
||||
category: API
|
||||
---
|
||||
|
||||
### ***def*** `set(self: Any, key: str, value: Any) -> None`
|
||||
|
||||
设置键值对
|
||||
Args:
|
||||
key: 键
|
||||
value: 值
|
||||
|
||||
### ***def*** `get(self: Any, key: str, default: Optional[Any]) -> Optional[Any]`
|
||||
|
||||
获取键值对
|
||||
Args:
|
||||
key: 键
|
||||
default: 默认值
|
||||
|
||||
Returns:
|
||||
Any: 值
|
||||
|
||||
### ***def*** `delete(self: Any, key: str, ignore_key_error: bool) -> None`
|
||||
|
||||
删除键值对
|
||||
Args:
|
||||
key: 键
|
||||
ignore_key_error: 是否忽略键不存在的错误
|
||||
|
||||
Returns:
|
||||
|
||||
### ***def*** `get_all(self: Any) -> dict[str, Any]`
|
||||
|
||||
获取所有键值对
|
||||
Returns:
|
||||
dict[str, Any]: 键值对
|
||||
|
||||
### ***def*** `get_instance(cls: Any) -> None`
|
||||
|
||||
|
||||
|
||||
### ***def*** `on_get(data: tuple[str, dict[str, Any]]) -> None`
|
||||
|
||||
|
||||
@ -61,53 +25,64 @@ Returns:
|
||||
|
||||
|
||||
|
||||
####   ***def*** `set(self: Any, key: str, value: Any) -> None`
|
||||
###   ***def*** `set(self: Any, key: str, value: Any) -> None`
|
||||
|
||||
 设置键值对
|
||||
|
||||
设置键值对
|
||||
Args:
|
||||
|
||||
key: 键
|
||||
|
||||
value: 值
|
||||
|
||||
####   ***def*** `get(self: Any, key: str, default: Optional[Any]) -> Optional[Any]`
|
||||
###   ***def*** `get(self: Any, key: str, default: Optional[Any]) -> Optional[Any]`
|
||||
|
||||
 获取键值对
|
||||
|
||||
获取键值对
|
||||
Args:
|
||||
|
||||
key: 键
|
||||
|
||||
default: 默认值
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
Any: 值
|
||||
|
||||
####   ***def*** `delete(self: Any, key: str, ignore_key_error: bool) -> None`
|
||||
###   ***def*** `delete(self: Any, key: str, ignore_key_error: bool) -> None`
|
||||
|
||||
 删除键值对
|
||||
|
||||
删除键值对
|
||||
Args:
|
||||
|
||||
key: 键
|
||||
|
||||
ignore_key_error: 是否忽略键不存在的错误
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
|
||||
####   ***def*** `get_all(self: Any) -> dict[str, Any]`
|
||||
###   ***def*** `get_all(self: Any) -> dict[str, Any]`
|
||||
|
||||
 获取所有键值对
|
||||
|
||||
获取所有键值对
|
||||
Returns:
|
||||
|
||||
dict[str, Any]: 键值对
|
||||
|
||||
### ***class*** `GlobalKeyValueStore`
|
||||
|
||||
|
||||
|
||||
#### `@classmethod`
|
||||
###   ***@classmethod***
|
||||
###   ***def*** `get_instance(cls: Any) -> None`
|
||||
|
||||
####   ***def*** `get_instance(cls: Any) -> None`
|
||||
 
|
||||
|
||||
|
||||
###   ***attr*** `_instance: None`
|
||||
|
||||
####   ***attr*** `_instance`
|
||||
|
||||
Type: None
|
||||
|
||||
####   ***attr*** `_lock`
|
||||
|
||||
Type: threading.Lock()
|
||||
###   ***attr*** `_lock: threading.Lock()`
|
||||
|
||||
|
Reference in New Issue
Block a user