1
0
forked from bot/app

Compare commits

..

No commits in common. "main" and "docs" have entirely different histories.
main ... docs

736 changed files with 9365 additions and 33393 deletions

View File

@ -1,53 +0,0 @@
---
name: 问题反馈
about: 反馈你在使用轻雪中遇到的问题
title: ''
labels: ''
assignees: ''
---
# 问题反馈
## **请确保**
- 已认真阅读[文档]("https://bot.liteyuki.icu"),该问题不是文档提及的或你自己操作不当造成的
- 你的问题是在最新版本的代码上测试的
- 请勿重复提交相同或类似的issue
## **描述问题**
请在此简单描述问题
## **如何复现**
请阐述一下如何重现这个问题
### 预期
描述你期望发生的事情
### 实际
描述实际发生的事情
## **日志或截图**
```
日志内容
```
## **设备信息**
- **系统**: [例如 Ubuntu 22.04]
- **CPU**: [例如 Intel i7-7700K]
- **内存**: [例如 16GB]
- **Python**: [例如CPython 3.10.7]
**补充内容**
可选,推荐提供`pip freeze`的输出,以及其他相关信息,以及你的建议

View File

@ -1,11 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

View File

@ -1,44 +0,0 @@
# 问题反馈
## **请确保**
- 已认真阅读[文档]("https://bot.liteyuki.icu"),该问题不是文档提及的或你自己操作不当造成的
- 你的问题是在最新版本的代码上测试的
- 请勿重复提交相同或类似的issue
## **描述问题**
请在此简单描述问题
## **如何复现**
请阐述一下如何重现这个问题
### 预期
描述你期望发生的事情
### 实际
描述实际发生的事情
## **日志或截图**
```
日志内容
```
## **设备信息**
- **系统**: [例如 Ubuntu 22.04]
- **CPU**: [例如 Intel i7-7700K]
- **内存**: [例如 16GB]
- **Python**: [例如CPython 3.10.7]
**补充内容**
可选,推荐提供`pip freeze`的输出,以及其他相关信息,以及你的建议

View File

@ -1,70 +0,0 @@
# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程
#
name: Deploy VitePress site to Pages
on:
# 在针对 `main` 分支的推送上运行。如果你
# 使用 `master` 分支作为默认分支,请将其更改为 `master`
push:
branches: [main]
# 允许你从 Actions 选项卡手动运行此工作流程
workflow_dispatch:
# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages
permissions:
contents: write
# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列
# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成
concurrency:
group: pages
cancel-in-progress: false
jobs:
# 构建工作
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # 如果未启用 lastUpdated则不需要
# - uses: pnpm/action-setup@v3 # 如果使用 pnpm请取消注释
# - uses: oven-sh/setup-bun@v1 # 如果使用 Bun请取消注释
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Setup API markdown
run: |-
python -m pip install litedoc
litedoc liteyuki -o docs/zh/dev/api -l zh-Hans -cd class -fd func -md func -vd var -cs -bu https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/
litedoc liteyuki -o docs/en/dev/api -l en -cd class -fd func -md func -vd var -cs -bu https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
run_install: true
version: 8
- name: 设置 Node.js
run: |-
cd docs
pnpm install
- name: 构建文档
env:
NODE_OPTIONS: --max_old_space_size=8192
run: |-
cd docs
pnpm run docs:build
> .vitepress/dist/.nojekyll
- name: 部署文档
uses: JamesIves/github-pages-deploy-action@v4
with:
# 这是文档部署到的分支名称
branch: docs
folder: docs/.vitepress/dist

View File

@ -1,20 +0,0 @@
name: Publish
on:
release:
types: [published]
jobs:
pypi-publish:
name: upload release to PyPI
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: pdm-project/setup-pdm@v3
- name: Publish package distributions to PyPI
run: pdm publish

67
.gitignore vendored
View File

@ -1,67 +0,0 @@
.venv/
.idea/
.vscode/
.cache/
venv/
node_modules/
data/
db/
/resources/
__pycache__/
*.pyc
*.pyo
*.pyd
*.pyw
/plugins/
#config
/config/
!config/default.yml
_config.yml
config.yml
config.example.yml
# vuepress
.github
# mupy
mypy.ini
# nuitka
compile.bat
src/resources/templates/latest-debug.html
main.build/
main.dist/
main.exe
main.cmd
docs/.vuepress/.cache/
docs/.vuepress/.temp/
docs/.vuepress/dist/
prompt.txt
# js
**/echarts.js
.env
# pdm
.pdm-python
.pdm-build
dist
doc
mkdoc2.py
result.json
# litedoc
docs/zh/dev/api
docs/en/dev/api
mkdoc.bat
# vitepress
docs/.vitepress/dist/
docs/.vitepress/cache
docs/.vitepress/.temp

23
404.html Normal file

File diff suppressed because one or more lines are too long

1
CNAME Normal file
View File

@ -0,0 +1 @@
bot.liteyuki.icu

View File

@ -1,19 +0,0 @@
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/python:3.10-slim-bullseye
ENV TZ Asia/Shanghai
COPY docker/sources.list /etc/apt/sources.list
RUN apt-get update && apt-get install -y git
WORKDIR /liteyukibot
COPY . /liteyukibot
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN apt-get install -y libnss3 libnspr4 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libasound2
EXPOSE 20216
CMD ["python", "main.py"]

31
LICENSE
View File

@ -1,31 +0,0 @@
LSO license
LiteyukiStudio Opensource license
---
版权所有 © 2024 Snowykami
---
免费向任何获得副本的人或组织授予以相同许可为基础的权利
包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件的副本
本软件及相关文档文件(以下简称"本软件")在相同方式许可为基础, 以开源的形式发布于互联网抑或其他媒体介质平台
任何人都有权利获取副本并以上述方式获取许可传播和/或使用
但获取副本时仍需注意:
- 上述版权声明和本许可声明应包含在本软件的副本中
- 使用本软件及其副本时仍需保持与原有形式相同
- 在使用时仍需将本软件的副本以相同许可公开表现:
- 不得未经原作者允许将本软件的副本以非原许可的形式对外盈利
---
该软件按"原样"之副本提供,不提供任何形式的任意保证,明示或暗示:
包括但不限于适销性保证, 适用于特定目的非侵权
在任何情况下, 作者或版权所有者对任何非因作者或版权所有者使用该软件造成的索赔、损害或其他责任, 无论是在合同诉讼、侵权行为还是其他诉讼中都不具有责任, 作者及其版权所有者有权利驳回使用者因个人原因造成的任何损失之赔付

View File

@ -1,51 +0,0 @@
<div align="center">
[//]: # (<img src="https://cdn.liteyuki.icu/static/svg/lylogo-full.svg" style="align-content: center; width: 50%; margin-top:10%;" alt="a">)
[![][banner]][lightyuki-link]
<h2><a href="https://bot.liteyuki.icu"> <span style="color: #a2d8f4">轻雪</span> <span style="color: #d0e9ff">6</span></a></h2>
<h4> <span style="color: #a2d8f4">✨ 轻量,高效,易于扩展✨</span></h4>
[![][OneBot]][onebot-link]
[![][NoneBot2]][nonebot-link]
[![][Liteyuki6.0]][lightyuki-link]
[![][Python3.10+]][python-link]
[![][Usage]][usage-link]
- 基于[Nonebot2](https://github.com/nonebot/nonebot2),有良好的生态支持
- 开箱即用,无需复杂配置
- 集成包管理器,支持一键安装插件
- 支持OneBot标准通信但不限于此
- 自定义主题支持,满足审美需求
- 国际化支持,支持多种语言
- 高性能500插件2s内启动
<h3>👇更多内容请访问👇</h3>
<h2><a href="https://bot.liteyuki.icu">轻雪机器人主页</a></h2>
</div>
### 感谢
- [NoneBot2](https://nonebot.dev)提供的框架支持
- [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna)提供的命令解析功能
[OneBot]: https://img.shields.io/badge/OneBot-11/12-blue?style=for-the-badge
[NoneBot2]: https://img.shields.io/badge/Nonebot-2-red?style=for-the-badge
[Liteyuki6.0]: https://img.shields.io/badge/Liteyuki-6.0-blue?style=for-the-badge
[Python3.10+]: https://img.shields.io/badge/Python-3.10+-blue?style=for-the-badge
[Usage]: https://img.shields.io/badge/文档-页面-blue?style=for-the-badge
[onebot-link]:https://onebot.dev/
[nonebot-link]:https://nonebot.dev/
[lightyuki-link]:/
[python-link]:https://www.python.org/
[usage-link]:https://bot.liteyuki.icu/
[banner]: https://socialify.git.ci/LiteyukiStudio/LiteyukiBot/image?description=1&forks=1&issues=1&Plus&pulls=1&stargazers=1&theme=Auto&logo=https%3a%2f%2fcdn.liteyuki.icu%2fstatic%2fsvg%2flylogo-full.svg

1
assets/app.CWfxCzjM.js Normal file
View File

@ -0,0 +1 @@
import{R as p}from"./chunks/theme.BleEYWi4.js";import{U as o,aa as u,ab as l,ac as c,ad as f,ae as d,af as m,ag as h,ah as g,ai as A,aj as y,d as P,u as v,y as w,x as C,ak as R,al as b,am as E,an as S}from"./chunks/framework.C4_mTacX.js";function i(e){if(e.extends){const a=i(e.extends);return{...a,...e,async enhanceApp(t){a.enhanceApp&&await a.enhanceApp(t),e.enhanceApp&&await e.enhanceApp(t)}}}return e}const s=i(p),T=P({name:"VitePressApp",setup(){const{site:e,lang:a,dir:t}=v();return w(()=>{C(()=>{document.documentElement.lang=a.value,document.documentElement.dir=t.value})}),e.value.router.prefetchLinks&&R(),b(),E(),s.setup&&s.setup(),()=>S(s.Layout)}});async function j(){globalThis.__VITEPRESS__=!0;const e=D(),a=x();a.provide(l,e);const t=c(e.route);return a.provide(f,t),a.component("Content",d),a.component("ClientOnly",m),Object.defineProperties(a.config.globalProperties,{$frontmatter:{get(){return t.frontmatter.value}},$params:{get(){return t.page.value.params}}}),s.enhanceApp&&await s.enhanceApp({app:a,router:e,siteData:h}),{app:a,router:e,data:t}}function x(){return g(T)}function D(){let e=o,a;return A(t=>{let n=y(t),r=null;return n&&(e&&(a=n),(e||a===n)&&(n=n.replace(/\.js$/,".lean.js")),r=import(n)),o&&(e=!1),r},s.NotFound)}o&&j().then(({app:e,router:a,data:t})=>{a.go().then(()=>{u(a.route,t.site),e.mount("#app")})});export{j as createApp};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,31 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"配置","description":"","frontmatter":{"title":"配置","order":2},"headers":[],"relativePath":"deploy/config.md","filePath":"zh/deploy/config.md","lastUpdated":1725101868000}'),t={name:"deploy/config.md"},l=n(`<h1 id="配置" tabindex="-1">配置 <a class="header-anchor" href="#配置" aria-label="Permalink to &quot;配置&quot;"></a></h1><p>轻雪支持<code>yaml</code>、<code>json</code>和<code>toml</code>作为配置文件,取决于你个人的喜好</p><p>首次运行后生成<code>config.yml</code>和<code>config</code>目录,你可修改配置项后重启轻雪,绝大多数情况下,你只需要修改<code>superusers</code>及<code>nickname</code>字段即可</p><p>启动时会加载项目目录下<code>config.yml/yaml/json/toml</code>和<code>config</code>目录下的所有配置文件,你可在<code>config</code>目录下创建多个配置文件,轻雪会自动合并这些配置文件</p><h2 id="基础配置项" tabindex="-1"><strong>基础配置项</strong> <a class="header-anchor" href="#基础配置项" aria-label="Permalink to &quot;**基础配置项**&quot;"></a></h2><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">nonebot</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # Nonebot机器人的配置以前的最外层配置项仍可为Nonebot服务但是部分内容会被覆盖请尽快迁移</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> command_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [ </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;/&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ] </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># &quot;&quot;alconna_use_command_startalconna</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> host</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">127.0.0.1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 0.0.0.0</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> port</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">20216</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> nickname</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [ </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;liteyuki&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ] </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> superusers</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [ </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;1919810&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ] </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">liteyuki</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 写在外层的配置项将会被覆盖建议迁移到liteyuki下</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> log_level</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;INFO&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> log_icon</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> auto_report</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> auto_update</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 4</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> plugins</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [ ] </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> plugin_dirs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [ ] </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># </span></span></code></pre></div><h2 id="" tabindex="-1"><strong></strong> <a class="header-anchor" href="#" aria-label="Permalink to &quot;****&quot;"></a></h2><p></p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># NoneBot</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">nonebot</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> onebot_access_token</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 访</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> default_language</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;zh-CN&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> alconna_auto_completion</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # alconnafalse</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> safe_mode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # NoneBot</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 其他Nonebot插件的配置项</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> custom_config_1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;custom_value1&quot;</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> custom_config_2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;custom_value2&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 开发者选项</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">liteyuki</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> allow_update</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # </span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> debug</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # Bot</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;"> dev_mode</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">false</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # </span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">...</span></span></code></pre></div><h2 id="-nonebotonebot" tabindex="-1"><strong>NoneBotOneBot</strong> <a class="header-anchor" href="#-nonebotonebot" aria-label="Permalink to &quot;**NoneBotOneBot**&quot;"></a></h2><p>WebSocket </p><table tabindex="0"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td></td><td>WebSocket</td><td>使ws</td></tr><tr><td></td><td>ws://127.0.0.1:20216/onebot/v11/ws</td><td><code>127.0.0.1:20216</code></td></tr><tr><td>AccessToken</td><td><code>&quot;&quot;</code></td><td><code>AccessToken</code></td></tr></tbody></table><ul><li>使访<a href="https://onebot.adapters.nonebot.dev/" target="_blank" rel="noreferrer">OneBot Adapter</a></li></ul><h2 id="" tabindex="-1"><strong></strong> <a class="header-anchor" href="#" aria-label="Permalink to &quot;****&quot;"></a></h2><ul><li>OneBot使NoneBot2使</li></ul>`,15),h=[l];function e(k,p,d,o,r,E){return a(),i("div",null,h)}const y=s(t,[["render",e]]);export{g as __pageData,y as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"配置","description":"","frontmatter":{"title":"配置","order":2},"headers":[],"relativePath":"deploy/config.md","filePath":"zh/deploy/config.md","lastUpdated":1725101868000}'),t={name:"deploy/config.md"},l=n("",15),h=[l];function e(k,p,d,o,r,E){return a(),i("div",null,h)}const y=s(t,[["render",e]]);export{g as __pageData,y as default};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
import{_ as e,c as o,o as t,a9 as a}from"./chunks/framework.C4_mTacX.js";const m=JSON.parse('{"title":"答疑","description":"","frontmatter":{"title":"答疑","order":3},"headers":[],"relativePath":"deploy/fandq.md","filePath":"zh/deploy/fandq.md","lastUpdated":1725101868000}'),r={name:"deploy/fandq.md"},n=a("",10),l=[n];function i(c,h,d,p,s,u){return t(),o("div",null,l)}const g=e(r,[["render",i]]);export{m as __pageData,g as default};

View File

@ -0,0 +1,8 @@
import{_ as i,c as e,o as t,a9 as s}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"安装","description":"","frontmatter":{"title":"安装","order":1},"headers":[],"relativePath":"deploy/install.md","filePath":"zh/deploy/install.md","lastUpdated":1725102337000}'),a={name:"deploy/install.md"},o=s(`<h1 id="安装" tabindex="-1">安装 <a class="header-anchor" href="#安装" aria-label="Permalink to &quot;安装&quot;"></a></h1><h2 id="常规部署" tabindex="-1"><strong>常规部署</strong> <a class="header-anchor" href="#常规部署" aria-label="Permalink to &quot;**常规部署**&quot;"></a></h2><ol><li>安装 <a href="https://git-scm.com/download/" target="_blank" rel="noreferrer"><code>Git</code></a> 和 <a href="https://www.python.org/downloads/release/python-31010/" target="_blank" rel="noreferrer"><code>Python3.10+</code></a> 环境</li></ol><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 克隆项目到本地轻雪使用Git进行版本管理该步骤为必要项</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> clone</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> https://github.com/LiteyukiStudio/LiteyukiBot</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> --depth=1</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 切换到Bot目录下</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> LiteyukiBot</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 安装依赖</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -r</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> requirements.txt</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 启动Bot</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">python</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> main.py</span></span></code></pre></div><div class="tip custom-block github-alert"><p class="custom-block-title">TIP</p><p>使使<code>python -m venv .venv</code>使<code>.venv\\Scripts\\activate</code>Linux使<code>source .venv/bin/activate</code></p></div><h2 id="使docker" tabindex="-1"><strong>使Docker</strong> <a class="header-anchor" href="#使docker" aria-label="Permalink to &quot;**使Docker**&quot;"></a></h2><ol><li> <a href="https://docs.docker.com/get-docker/" target="_blank" rel="noreferrer"><code>Docker</code></a></li><li> <code>git clone https://github.com/LiteyukiStudio/LiteyukiBot --depth=1</code></li><li> <code>cd LiteyukiBot</code></li><li> <code>docker build -t liteyukibot .</code></li><li> <code>docker run -p 20216:20216 -v $(pwd):/liteyukibot -v $(pwd)/.cache:/root/.cache liteyukibot</code></li></ol><div class="tip custom-block github-alert"><p class="custom-block-title">TIP</p><p>Windows使<code>/path/to/LiteyukiBot</code><code>$(pwd)</code> <br> <code>20216:20216</code><code>20216</code></p></div><h2 id="使trss-scripts" tabindex="-1"><strong>使TRSS Scripts</strong> <a class="header-anchor" href="#使trss-scripts" aria-label="Permalink to &quot;**使TRSS Scripts**&quot;"></a></h2><p><a href="https://timerainstarsky.github.io/TRSS_Liteyuki/" target="_blank" rel="noreferrer">TRSS_Liteyuki</a>TRSSLiteyukiBot使<code>Arch Linux</code></p><h2 id="" tabindex="-1"><strong></strong> <a class="header-anchor" href="#" aria-label="Permalink to &quot;****&quot;"></a></h2><ul><li>Windows<code>Windows10+</code>/<code>Windows Server 2019+</code></li><li>LinuxPython3.10+<code>Ubuntu 20.04+</code>(<s>b CentOS</s>)</li><li>CPU: <code>1vCPU</code></li><li>: Bot<code>300~500MB</code><code>chromium</code> <code>node</code><code>1GB</code></li><li>: <code>1GB</code></li></ul><div class="warning custom-block github-alert"><p class="custom-block-title">WARNING</p><p>使<code>path/to/python -m pip install -r requirements.txt</code><code>path/to/python</code>Python</p></div><div class="warning custom-block github-alert"><p class="custom-block-title">WARNING</p><p>GitGit使</p></div><h4 id="" tabindex="-1"><a href="./fandq.html"></a> <a class="header-anchor" href="#" aria-label="Permalink to &quot;[](./fandq)&quot;"></a></h4>`,15),l=[o];function n(c,d,r,h,p,k){return t(),e("div",null,l)}const b=i(a,[["render",n]]);export{g as __pageData,b as default};

View File

@ -0,0 +1 @@
import{_ as i,c as e,o as t,a9 as s}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"安装","description":"","frontmatter":{"title":"安装","order":1},"headers":[],"relativePath":"deploy/install.md","filePath":"zh/deploy/install.md","lastUpdated":1725102337000}'),a={name:"deploy/install.md"},o=s("",15),l=[o];function n(c,d,r,h,p,k){return t(),e("div",null,l)}const b=i(a,[["render",n]]);export{g as __pageData,b as default};

View File

@ -0,0 +1 @@
import{_ as e,c as a,o as t,a9 as i}from"./chunks/framework.C4_mTacX.js";const v=JSON.parse('{"title":"liteyuki API","description":"","frontmatter":{"title":"liteyuki API","collapsed":true,"order":100},"headers":[],"relativePath":"dev/api/api.md","filePath":"zh/dev/api/api.md","lastUpdated":null}'),o={name:"dev/api/api.md"},r=i('<h1 id="liteyuki" tabindex="-1">liteyuki <a class="header-anchor" href="#liteyuki" aria-label="Permalink to &quot;liteyuki&quot;"></a></h1><p>此模块为liteyuki的框架整体</p><p>This module is the overall framework of liteyuki.</p><h3 id="var-version" tabindex="-1">var <code>__version__</code> <a class="header-anchor" href="#var-version" aria-label="Permalink to &quot;var `__version__`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 测试版本号</p></li><li><p><strong>默认值</strong>: <code>&#39;6.3.10&#39;</code></p></li></ul>',5),l=[r];function s(_,n,d,c,p,u){return t(),a("div",null,l)}const k=e(o,[["render",s]]);export{v as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as e,c as a,o as t,a9 as i}from"./chunks/framework.C4_mTacX.js";const v=JSON.parse('{"title":"liteyuki API","description":"","frontmatter":{"title":"liteyuki API","collapsed":true,"order":100},"headers":[],"relativePath":"dev/api/api.md","filePath":"zh/dev/api/api.md","lastUpdated":null}'),o={name:"dev/api/api.md"},r=i("",5),l=[r];function s(_,n,d,c,p,u){return t(),a("div",null,l)}const k=e(o,[["render",s]]);export{v as __pageData,k as default};

View File

@ -0,0 +1,181 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.bot","description":"","frontmatter":{"title":"liteyuki.bot","collapsed":true},"headers":[],"relativePath":"dev/api/bot/bot.md","filePath":"zh/dev/api/bot/bot.md","lastUpdated":null}'),t={name:"dev/api/bot/bot.md"},l=n(`<h1 id="liteyuki-bot" tabindex="-1">liteyuki.bot <a class="header-anchor" href="#liteyuki-bot" aria-label="Permalink to &quot;liteyuki.bot&quot;"></a></h1><h3 id="class-liteyukibot" tabindex="-1"><em><strong>class</strong></em> <code>LiteyukiBot</code> <a class="header-anchor" href="#class-liteyukibot" aria-label="Permalink to &quot;***class*** \`LiteyukiBot\`&quot;"></a></h3><h4 id="func-init-self-kwargs-none" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, **kwargs) -&gt; None</code> <a class="header-anchor" href="#func-init-self-kwargs-none" aria-label="Permalink to &quot;***func*** \`__init__(self, **kwargs) -&gt; None\`&quot;"></a></h4><p><strong>说明</strong>: 初始化轻雪实例</p><p><strong>参数</strong>:</p><blockquote><ul><li>**kwargs: 配置</li></ul></blockquote><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L27" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 初始化轻雪实例</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> **kwargs: 配置</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;常规操作&#39;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> print_logo()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> global</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> _BOT_INSTANCE</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> _BOT_INSTANCE</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;配置&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.config: dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> kwargs</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;初始化&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.init(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.config)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Liteyuki is initializing...&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;生命周期管理&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Lifespan()</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager: ProcessManager </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ProcessManager(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">lifespan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan)</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;事件循环&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.loop </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.new_event_loop()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.set_event_loop(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.loop)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop_event </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> threading.Event()</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.call_restart_count </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;加载插件加载器&#39;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_plugin(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;liteyuki.plugins.plugin_loader&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h4 id="func-run-self" tabindex="-1"><em><strong>func</strong></em> <code>run(self)</code> <a class="header-anchor" href="#func-run-self" aria-label="Permalink to &quot;***func*** \`run(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L66" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> run</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 外部启动接口</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager.start_all()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.run(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._run())</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> KeyboardInterrupt</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.opt(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">colors</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;y&gt;Liteyuki is stopping...&lt;/y&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.opt(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">colors</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;y&gt;Liteyuki is stopped...&lt;/y&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h4 id="async-func-keep-alive-self" tabindex="-1"><em><strong>async func</strong></em> <code>keep_alive(self)</code> <a class="header-anchor" href="#async-func-keep-alive-self" aria-label="Permalink to &quot;***async func*** \`keep_alive(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L78" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> keep_alive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 保持轻雪运行</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Liteyuki is keeping alive...&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> while</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop_event.is_set():</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.sleep(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Exception</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Liteyuki is exiting...&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop()</span></span></code></pre></div></details><h4 id="func-restart-self-delay-int-0" tabindex="-1"><em><strong>func</strong></em> <code>restart(self, delay: int = 0)</code> <a class="header-anchor" href="#func-restart-self-delay-int-0" aria-label="Permalink to &quot;***func*** \`restart(self, delay: int = 0)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>delay (<a href="https://docs.python.org/3/library/functions.html#int" target="_blank" rel="noreferrer"><code>int</code></a>, optional): . Defaults to 0.</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L90" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, delay: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">int</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 重启轻雪本体</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> delay ([\`int\`](https%3A//docs.python.org/3/library/functions.html#int), optional): 延迟重启时间. Defaults to 0.</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.call_restart_count </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&lt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> executable </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> sys.executable</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> args </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> sys.argv</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Restarting LiteyukiBot...&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> time.sleep(delay)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> platform.system() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;Windows&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cmd </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;start&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> platform.system() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;Linux&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cmd </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;nohup&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> platform.system() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;Darwin&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cmd </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;open&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cmd </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;nohup&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager.terminate_all()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> threading.Thread(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">target</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">os.system, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">args</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">cmd</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> {</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">executable</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39; &#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.join(args)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,), </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">daemon</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).start()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> sys.exit(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.call_restart_count </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span></span></code></pre></div></details><h4 id="func-restart-process-self-name-optional-str-none" tabindex="-1"><em><strong>func</strong></em> <code>restart_process(self, name: Optional[str] = None)</code> <a class="header-anchor" href="#func-restart-process-self-name-optional-str-none" aria-label="Permalink to &quot;***func*** \`restart_process(self, name: Optional[str] = None)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>name (<a href="https://docs.python.org/3/library/typing.html#typing.Optional" target="_blank" rel="noreferrer"><code>Optional</code></a>[<a href="https://docs.python.org/3/library/stdtypes.html#str" target="_blank" rel="noreferrer"><code>str</code></a>]): . Defaults to None.</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L115" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> restart_process</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, name: Optional[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 停止轻雪</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name ([\`Optional\`](https%3A//docs.python.org/3/library/typing.html#typing.Optional)[[\`str\`](https%3A//docs.python.org/3/library/stdtypes.html#str)]): 进程名. Defaults to None.</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_channel(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">-active&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active.send(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> process_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager.processes:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_channel(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">process_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">-active&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active.send(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h4 id="func-init-self-args-kwargs" tabindex="-1"><em><strong>func</strong></em> <code>init(self, *args, **kwargs)</code> <a class="header-anchor" href="#func-init-self-args-kwargs" aria-label="Permalink to &quot;***func*** \`init(self, *args, **kwargs)\`&quot;"></a></h4><p><strong></strong>: , </p><p><strong></strong>:</p><blockquote><ul><li>*args: </li><li>**kwargs: </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L130" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> init</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 初始化轻雪, 自动调用</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> *args: 参数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> **kwargs: 关键字参数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.init_logger()</span></span></code></pre></div></details><h4 id="func-init-logger-self" tabindex="-1"><em><strong>func</strong></em> <code>init_logger(self)</code> <a class="header-anchor" href="#func-init-logger-self" aria-label="Permalink to &quot;***func*** \`init_logger(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L139" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> init_logger</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 初始化日志</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> init_log(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">config</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.config)</span></span></code></pre></div></details><h4 id="func-stop-self" tabindex="-1"><em><strong>func</strong></em> <code>stop(self)</code> <a class="header-anchor" href="#func-stop-self" aria-label="Permalink to &quot;***func*** \`stop(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L145" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> stop</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 停止轻雪</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager.terminate_all()</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop_event.set()</span></span></code></pre></div></details><h4 id="func-on-before-start-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L152" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册启动前的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_before_start(func)</span></span></code></pre></div></details><h4 id="func-on-after-start-self-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_start(self, func: LIFESPAN_FUNC)</code> <a class="header-anchor" href="#func-on-after-start-self-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_start(self, func: LIFESPAN_FUNC)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L162" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册启动后的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_after_start(func)</span></span></code></pre></div></details><h4 id="func-on-after-shutdown-self-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_shutdown(self, func: LIFESPAN_FUNC)</code> <a class="header-anchor" href="#func-on-after-shutdown-self-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_shutdown(self, func: LIFESPAN_FUNC)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L172" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册停止后的函数未实现</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_after_shutdown(func)</span></span></code></pre></div></details><h4 id="func-on-before-process-shutdown-self-func-process-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC)</code> <a class="header-anchor" href="#func-on-before-process-shutdown-self-func-process-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L182" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_process_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册进程停止前的函数为子进程停止时调用</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`PROCESS_LIFESPAN_FUNC\`](./lifespan#var-process-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`PROCESS_LIFESPAN_FUNC\`](./lifespan#var-process-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_before_process_shutdown(func)</span></span></code></pre></div></details><h4 id="func-on-before-process-restart-self-func-process-lifespan-func-process-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-process-restart-self-func-process-lifespan-func-process-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L192" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_process_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册进程重启前的函数为子进程重启时调用</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`PROCESS_LIFESPAN_FUNC\`](./lifespan#var-process-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`PROCESS_LIFESPAN_FUNC\`](./lifespan#var-process-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_before_process_restart(func)</span></span></code></pre></div></details><h4 id="func-on-after-restart-self-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_restart(self, func: LIFESPAN_FUNC)</code> <a class="header-anchor" href="#func-on-after-restart-self-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_restart(self, func: LIFESPAN_FUNC)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L203" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册重启后的函数未实现</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_after_restart(func)</span></span></code></pre></div></details><h3 id="func-get-bot-liteyukibot" tabindex="-1"><em><strong>func</strong></em> <code>get_bot() -&gt; LiteyukiBot</code> <a class="header-anchor" href="#func-get-bot-liteyukibot" aria-label="Permalink to &quot;***func*** \`get_bot() -&gt; LiteyukiBot\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>: <a href="#class-liteyukibot"><code>LiteyukiBot</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L217" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_bot</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() -&gt; LiteyukiBot:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取轻雪实例</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LiteyukiBot\`](#class-liteyukibot): 轻雪实例</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> _BOT_INSTANCE</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> is</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> raise</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> RuntimeError</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Liteyuki instance not initialized.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> _BOT_INSTANCE</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> raise</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> RuntimeError</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Can&#39;t get bot instance in sub process.&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h3 id="func-get-config-key-str-default-any-none-any" tabindex="-1"><em><strong>func</strong></em> <code>get_config(key: str, default: Any = None) -&gt; Any</code> <a class="header-anchor" href="#func-get-config-key-str-default-any-none-any" aria-label="Permalink to &quot;***func*** \`get_config(key: str, default: Any = None) -&gt; Any\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>key (<a href="https://docs.python.org/3/library/stdtypes.html#str" target="_blank" rel="noreferrer"><code>str</code></a>): </li><li>default (<a href="https://docs.python.org/3/library/functions.html#any" target="_blank" rel="noreferrer"><code>Any</code></a>, optional): . Defaults to None.</li></ul></blockquote><p><strong></strong>: <a href="https://docs.python.org/3/library/functions.html#any" target="_blank" rel="noreferrer"><code>Any</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L232" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_config</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(key: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, default: Any</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Any:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取配置</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key ([\`str\`](https%3A//docs.python.org/3/library/stdtypes.html#str)): 配置键</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> default ([\`Any\`](https%3A//docs.python.org/3/library/functions.html#any), optional): 默认值. Defaults to None.</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`Any\`](https%3A//docs.python.org/3/library/functions.html#any): 配置值</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config.get(key, default)</span></span></code></pre></div></details><h3 id="func-get-config-with-compat-key-str-compat-keys-tuple-str-default-any-none-any" tabindex="-1"><em><strong>func</strong></em> <code>get_config_with_compat(key: str, compat_keys: tuple[str], default: Any = None) -&gt; Any</code> <a class="header-anchor" href="#func-get-config-with-compat-key-str-compat-keys-tuple-str-default-any-none-any" aria-label="Permalink to &quot;***func*** \`get_config_with_compat(key: str, compat_keys: tuple[str], default: Any = None) -&gt; Any\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>key (<a href="https://docs.python.org/3/library/stdtypes.html#str" target="_blank" rel="noreferrer"><code>str</code></a>): </li><li>compat_keys (<a href="https://docs.python.org/3/library/stdtypes.html#tuple" target="_blank" rel="noreferrer"><code>tuple</code></a><a href="https://docs.python.org/3/library/stdtypes.html#str" target="_blank" rel="noreferrer"><code>str</code></a>): </li><li>default (<a href="https://docs.python.org/3/library/functions.html#any" target="_blank" rel="noreferrer"><code>Any</code></a>, optional): . Defaults to None.</li></ul></blockquote><p><strong></strong>: <a href="https://docs.python.org/3/library/functions.html#any" target="_blank" rel="noreferrer"><code>Any</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L244" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_config_with_compat</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(key: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, compat_keys: tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], default: Any</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Any:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取配置兼容旧版本</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key ([\`str\`](https%3A//docs.python.org/3/library/stdtypes.html#str)): 配置键</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> compat_keys ([\`tuple\`](https%3A//docs.python.org/3/library/stdtypes.html#tuple)[\`str\`](https%3A//docs.python.org/3/library/stdtypes.html#str)): 兼容键</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> default ([\`Any\`](https%3A//docs.python.org/3/library/functions.html#any), optional): 默认值. Defaults to None.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`Any\`](https%3A//docs.python.org/3/library/functions.html#any): 配置值</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config[key]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> compat_key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> compat_keys:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> compat_key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Config key &quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">compat_key</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot; will be deprecated, use &quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">key</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot; instead.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config[compat_key]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> default</span></span></code></pre></div></details>`,86),e=[l];function p(h,k,r,o,d,g){return a(),i("div",null,e)}const c=s(t,[["render",p]]);export{y as __pageData,c as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.bot","description":"","frontmatter":{"title":"liteyuki.bot","collapsed":true},"headers":[],"relativePath":"dev/api/bot/bot.md","filePath":"zh/dev/api/bot/bot.md","lastUpdated":null}'),t={name:"dev/api/bot/bot.md"},l=n("",86),e=[l];function p(h,k,r,o,d,g){return a(),i("div",null,e)}const c=s(t,[["render",p]]);export{y as __pageData,c as default};

View File

@ -0,0 +1,181 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.bot","description":"","frontmatter":{"title":"liteyuki.bot","collapsed":true},"headers":[],"relativePath":"dev/api/bot/index.md","filePath":"zh/dev/api/bot/index.md","lastUpdated":null}'),t={name:"dev/api/bot/index.md"},l=n(`<h1 id="liteyuki-bot" tabindex="-1">liteyuki.bot <a class="header-anchor" href="#liteyuki-bot" aria-label="Permalink to &quot;liteyuki.bot&quot;"></a></h1><h3 id="class-liteyukibot" tabindex="-1"><em><strong>class</strong></em> <code>LiteyukiBot</code> <a class="header-anchor" href="#class-liteyukibot" aria-label="Permalink to &quot;***class*** \`LiteyukiBot\`&quot;"></a></h3><h4 id="func-init-self-kwargs-none" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, **kwargs) -&gt; None</code> <a class="header-anchor" href="#func-init-self-kwargs-none" aria-label="Permalink to &quot;***func*** \`__init__(self, **kwargs) -&gt; None\`&quot;"></a></h4><p><strong>说明</strong>: 初始化轻雪实例</p><p><strong>参数</strong>:</p><blockquote><ul><li>**kwargs: 配置</li></ul></blockquote><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L27" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 初始化轻雪实例</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> **kwargs: 配置</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;常规操作&#39;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> print_logo()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> global</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> _BOT_INSTANCE</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> _BOT_INSTANCE</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;配置&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.config: dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> kwargs</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;初始化&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.init(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.config)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Liteyuki is initializing...&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;生命周期管理&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Lifespan()</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager: ProcessManager </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ProcessManager(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">lifespan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan)</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;事件循环&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.loop </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.new_event_loop()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.set_event_loop(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.loop)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop_event </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> threading.Event()</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.call_restart_count </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;加载插件加载器&#39;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_plugin(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;liteyuki.plugins.plugin_loader&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h4 id="func-run-self" tabindex="-1"><em><strong>func</strong></em> <code>run(self)</code> <a class="header-anchor" href="#func-run-self" aria-label="Permalink to &quot;***func*** \`run(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L66" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> run</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 外部启动接口</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager.start_all()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.run(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._run())</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> KeyboardInterrupt</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.opt(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">colors</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;y&gt;Liteyuki is stopping...&lt;/y&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.opt(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">colors</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;y&gt;Liteyuki is stopped...&lt;/y&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h4 id="async-func-keep-alive-self" tabindex="-1"><em><strong>async func</strong></em> <code>keep_alive(self)</code> <a class="header-anchor" href="#async-func-keep-alive-self" aria-label="Permalink to &quot;***async func*** \`keep_alive(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L78" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> keep_alive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 保持轻雪运行</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Liteyuki is keeping alive...&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> while</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop_event.is_set():</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.sleep(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Exception</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Liteyuki is exiting...&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop()</span></span></code></pre></div></details><h4 id="func-restart-self-delay-int-0" tabindex="-1"><em><strong>func</strong></em> <code>restart(self, delay: int = 0)</code> <a class="header-anchor" href="#func-restart-self-delay-int-0" aria-label="Permalink to &quot;***func*** \`restart(self, delay: int = 0)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>delay (<a href="https://docs.python.org/3/library/functions.html#int" target="_blank" rel="noreferrer"><code>int</code></a>, optional): . Defaults to 0.</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L90" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, delay: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">int</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 重启轻雪本体</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> delay ([\`int\`](https%3A//docs.python.org/3/library/functions.html#int), optional): 延迟重启时间. Defaults to 0.</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.call_restart_count </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&lt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> executable </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> sys.executable</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> args </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> sys.argv</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Restarting LiteyukiBot...&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> time.sleep(delay)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> platform.system() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;Windows&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cmd </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;start&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> platform.system() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;Linux&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cmd </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;nohup&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> platform.system() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;Darwin&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cmd </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;open&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cmd </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;nohup&#39;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager.terminate_all()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> threading.Thread(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">target</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">os.system, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">args</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">cmd</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> {</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">executable</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39; &#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.join(args)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,), </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">daemon</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).start()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> sys.exit(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.call_restart_count </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span></span></code></pre></div></details><h4 id="func-restart-process-self-name-optional-str-none" tabindex="-1"><em><strong>func</strong></em> <code>restart_process(self, name: Optional[str] = None)</code> <a class="header-anchor" href="#func-restart-process-self-name-optional-str-none" aria-label="Permalink to &quot;***func*** \`restart_process(self, name: Optional[str] = None)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>name (<a href="https://docs.python.org/3/library/typing.html#typing.Optional" target="_blank" rel="noreferrer"><code>Optional</code></a>[<a href="https://docs.python.org/3/library/stdtypes.html#str" target="_blank" rel="noreferrer"><code>str</code></a>]): . Defaults to None.</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L115" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> restart_process</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, name: Optional[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 停止轻雪</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name ([\`Optional\`](https%3A//docs.python.org/3/library/typing.html#typing.Optional)[[\`str\`](https%3A//docs.python.org/3/library/stdtypes.html#str)]): 进程名. Defaults to None.</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_channel(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">-active&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active.send(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> process_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager.processes:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_channel(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">process_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">-active&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active.send(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h4 id="func-init-self-args-kwargs" tabindex="-1"><em><strong>func</strong></em> <code>init(self, *args, **kwargs)</code> <a class="header-anchor" href="#func-init-self-args-kwargs" aria-label="Permalink to &quot;***func*** \`init(self, *args, **kwargs)\`&quot;"></a></h4><p><strong></strong>: , </p><p><strong></strong>:</p><blockquote><ul><li>*args: </li><li>**kwargs: </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L130" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> init</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 初始化轻雪, 自动调用</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> *args: 参数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> **kwargs: 关键字参数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.init_logger()</span></span></code></pre></div></details><h4 id="func-init-logger-self" tabindex="-1"><em><strong>func</strong></em> <code>init_logger(self)</code> <a class="header-anchor" href="#func-init-logger-self" aria-label="Permalink to &quot;***func*** \`init_logger(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L139" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> init_logger</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 初始化日志</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> init_log(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">config</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.config)</span></span></code></pre></div></details><h4 id="func-stop-self" tabindex="-1"><em><strong>func</strong></em> <code>stop(self)</code> <a class="header-anchor" href="#func-stop-self" aria-label="Permalink to &quot;***func*** \`stop(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L145" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> stop</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 停止轻雪</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.process_manager.terminate_all()</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.stop_event.set()</span></span></code></pre></div></details><h4 id="func-on-before-start-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L152" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册启动前的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_before_start(func)</span></span></code></pre></div></details><h4 id="func-on-after-start-self-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_start(self, func: LIFESPAN_FUNC)</code> <a class="header-anchor" href="#func-on-after-start-self-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_start(self, func: LIFESPAN_FUNC)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L162" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册启动后的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_after_start(func)</span></span></code></pre></div></details><h4 id="func-on-after-shutdown-self-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_shutdown(self, func: LIFESPAN_FUNC)</code> <a class="header-anchor" href="#func-on-after-shutdown-self-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_shutdown(self, func: LIFESPAN_FUNC)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L172" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册停止后的函数未实现</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_after_shutdown(func)</span></span></code></pre></div></details><h4 id="func-on-before-process-shutdown-self-func-process-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC)</code> <a class="header-anchor" href="#func-on-before-process-shutdown-self-func-process-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L182" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_process_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册进程停止前的函数为子进程停止时调用</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`PROCESS_LIFESPAN_FUNC\`](./lifespan#var-process-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`PROCESS_LIFESPAN_FUNC\`](./lifespan#var-process-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_before_process_shutdown(func)</span></span></code></pre></div></details><h4 id="func-on-before-process-restart-self-func-process-lifespan-func-process-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-process-restart-self-func-process-lifespan-func-process-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L192" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_process_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册进程重启前的函数为子进程重启时调用</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`PROCESS_LIFESPAN_FUNC\`](./lifespan#var-process-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`PROCESS_LIFESPAN_FUNC\`](./lifespan#var-process-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_before_process_restart(func)</span></span></code></pre></div></details><h4 id="func-on-after-restart-self-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_restart(self, func: LIFESPAN_FUNC)</code> <a class="header-anchor" href="#func-on-after-restart-self-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_restart(self, func: LIFESPAN_FUNC)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="./lifespan.html#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L203" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册重启后的函数未实现</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](./lifespan#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan.on_after_restart(func)</span></span></code></pre></div></details><h3 id="func-get-bot-liteyukibot" tabindex="-1"><em><strong>func</strong></em> <code>get_bot() -&gt; LiteyukiBot</code> <a class="header-anchor" href="#func-get-bot-liteyukibot" aria-label="Permalink to &quot;***func*** \`get_bot() -&gt; LiteyukiBot\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>: <a href="#class-liteyukibot"><code>LiteyukiBot</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L217" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_bot</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() -&gt; LiteyukiBot:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取轻雪实例</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LiteyukiBot\`](#class-liteyukibot): 轻雪实例</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> _BOT_INSTANCE</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> is</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> raise</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> RuntimeError</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Liteyuki instance not initialized.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> _BOT_INSTANCE</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> raise</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> RuntimeError</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Can&#39;t get bot instance in sub process.&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h3 id="func-get-config-key-str-default-any-none-any" tabindex="-1"><em><strong>func</strong></em> <code>get_config(key: str, default: Any = None) -&gt; Any</code> <a class="header-anchor" href="#func-get-config-key-str-default-any-none-any" aria-label="Permalink to &quot;***func*** \`get_config(key: str, default: Any = None) -&gt; Any\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>key (<a href="https://docs.python.org/3/library/stdtypes.html#str" target="_blank" rel="noreferrer"><code>str</code></a>): </li><li>default (<a href="https://docs.python.org/3/library/functions.html#any" target="_blank" rel="noreferrer"><code>Any</code></a>, optional): . Defaults to None.</li></ul></blockquote><p><strong></strong>: <a href="https://docs.python.org/3/library/functions.html#any" target="_blank" rel="noreferrer"><code>Any</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L232" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_config</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(key: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, default: Any</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Any:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取配置</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key ([\`str\`](https%3A//docs.python.org/3/library/stdtypes.html#str)): 配置键</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> default ([\`Any\`](https%3A//docs.python.org/3/library/functions.html#any), optional): 默认值. Defaults to None.</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`Any\`](https%3A//docs.python.org/3/library/functions.html#any): 配置值</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config.get(key, default)</span></span></code></pre></div></details><h3 id="func-get-config-with-compat-key-str-compat-keys-tuple-str-default-any-none-any" tabindex="-1"><em><strong>func</strong></em> <code>get_config_with_compat(key: str, compat_keys: tuple[str], default: Any = None) -&gt; Any</code> <a class="header-anchor" href="#func-get-config-with-compat-key-str-compat-keys-tuple-str-default-any-none-any" aria-label="Permalink to &quot;***func*** \`get_config_with_compat(key: str, compat_keys: tuple[str], default: Any = None) -&gt; Any\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>key (<a href="https://docs.python.org/3/library/stdtypes.html#str" target="_blank" rel="noreferrer"><code>str</code></a>): </li><li>compat_keys (<a href="https://docs.python.org/3/library/stdtypes.html#tuple" target="_blank" rel="noreferrer"><code>tuple</code></a><a href="https://docs.python.org/3/library/stdtypes.html#str" target="_blank" rel="noreferrer"><code>str</code></a>): </li><li>default (<a href="https://docs.python.org/3/library/functions.html#any" target="_blank" rel="noreferrer"><code>Any</code></a>, optional): . Defaults to None.</li></ul></blockquote><p><strong></strong>: <a href="https://docs.python.org/3/library/functions.html#any" target="_blank" rel="noreferrer"><code>Any</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/__init__.py#L244" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_config_with_compat</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(key: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, compat_keys: tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], default: Any</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Any:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取配置兼容旧版本</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key ([\`str\`](https%3A//docs.python.org/3/library/stdtypes.html#str)): 配置键</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> compat_keys ([\`tuple\`](https%3A//docs.python.org/3/library/stdtypes.html#tuple)[\`str\`](https%3A//docs.python.org/3/library/stdtypes.html#str)): 兼容键</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> default ([\`Any\`](https%3A//docs.python.org/3/library/functions.html#any), optional): 默认值. Defaults to None.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`Any\`](https%3A//docs.python.org/3/library/functions.html#any): 配置值</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config[key]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> compat_key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> compat_keys:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> compat_key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Config key &quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">compat_key</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot; will be deprecated, use &quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">key</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot; instead.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_bot().config[compat_key]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> default</span></span></code></pre></div></details>`,86),e=[l];function p(h,k,r,o,d,g){return a(),i("div",null,e)}const c=s(t,[["render",p]]);export{y as __pageData,c as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.bot","description":"","frontmatter":{"title":"liteyuki.bot","collapsed":true},"headers":[],"relativePath":"dev/api/bot/index.md","filePath":"zh/dev/api/bot/index.md","lastUpdated":null}'),t={name:"dev/api/bot/index.md"},l=n("",86),e=[l];function p(h,k,r,o,d,g){return a(),i("div",null,e)}const c=s(t,[["render",p]]);export{y as __pageData,c as default};

View File

@ -0,0 +1,104 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const u=JSON.parse('{"title":"liteyuki.bot.lifespan","description":"","frontmatter":{"title":"liteyuki.bot.lifespan"},"headers":[],"relativePath":"dev/api/bot/lifespan.md","filePath":"zh/dev/api/bot/lifespan.md","lastUpdated":null}'),t={name:"dev/api/bot/lifespan.md"},e=n(`<h1 id="liteyuki-bot-lifespan" tabindex="-1">liteyuki.bot.lifespan <a class="header-anchor" href="#liteyuki-bot-lifespan" aria-label="Permalink to &quot;liteyuki.bot.lifespan&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/7/23 下午8:24 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : lifespan.py @Software: PyCharm</p><h3 id="var-sync-lifespan-func" tabindex="-1">var <code>SYNC_LIFESPAN_FUNC</code> <a class="header-anchor" href="#var-sync-lifespan-func" aria-label="Permalink to &quot;var \`SYNC_LIFESPAN_FUNC\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 同步生命周期函数</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>Callable[[], Any]</code></p></li></ul><h3 id="var-async-lifespan-func" tabindex="-1">var <code>ASYNC_LIFESPAN_FUNC</code> <a class="header-anchor" href="#var-async-lifespan-func" aria-label="Permalink to &quot;var \`ASYNC_LIFESPAN_FUNC\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 异步生命周期函数</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>Callable[[], Awaitable[Any]]</code></p></li></ul><h3 id="var-lifespan-func" tabindex="-1">var <code>LIFESPAN_FUNC</code> <a class="header-anchor" href="#var-lifespan-func" aria-label="Permalink to &quot;var \`LIFESPAN_FUNC\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 生命周期函数</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>SYNC_LIFESPAN_FUNC | ASYNC_LIFESPAN_FUNC</code></p></li></ul><h3 id="var-sync-process-lifespan-func" tabindex="-1">var <code>SYNC_PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#var-sync-process-lifespan-func" aria-label="Permalink to &quot;var \`SYNC_PROCESS_LIFESPAN_FUNC\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 同步进程生命周期函数</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>Callable[[str], Any]</code></p></li></ul><h3 id="var-async-process-lifespan-func" tabindex="-1">var <code>ASYNC_PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#var-async-process-lifespan-func" aria-label="Permalink to &quot;var \`ASYNC_PROCESS_LIFESPAN_FUNC\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 异步进程生命周期函数</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>Callable[[str], Awaitable[Any]]</code></p></li></ul><h3 id="var-process-lifespan-func" tabindex="-1">var <code>PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#var-process-lifespan-func" aria-label="Permalink to &quot;var \`PROCESS_LIFESPAN_FUNC\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 进程函数</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>SYNC_PROCESS_LIFESPAN_FUNC | ASYNC_PROCESS_LIFESPAN_FUNC</code></p></li></ul><h3 id="class-lifespan" tabindex="-1"><em><strong>class</strong></em> <code>Lifespan</code> <a class="header-anchor" href="#class-lifespan" aria-label="Permalink to &quot;***class*** \`Lifespan\`&quot;"></a></h3><h4 id="func-init-self-none" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self) -&gt; None</code> <a class="header-anchor" href="#func-init-self-none" aria-label="Permalink to &quot;***func*** \`__init__(self) -&gt; None\`&quot;"></a></h4><p><strong>说明</strong>: 轻雪生命周期管理,启动、停止、重启</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L27" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 轻雪生命周期管理启动停止重启</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.life_flag: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">int</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_start_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_start_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_shutdown_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_shutdown_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_restart_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_restart_funcs: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span></code></pre></div></details><p><a href="https://docs.python.org/3/library/functions.html#staticmethod" target="_blank" rel="noreferrer"><code>@staticmethod</code></a></p><h4 id="async-func-run-funcs-funcs-sequence-lifespan-func-process-lifespan-func-args-kwargs-none" tabindex="-1"><em><strong>async func</strong></em> <code>run_funcs(funcs: Sequence[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC], *args, **kwargs) -&gt; None</code> <a class="header-anchor" href="#async-func-run-funcs-funcs-sequence-lifespan-func-process-lifespan-func-args-kwargs-none" aria-label="Permalink to &quot;***async func*** \`run_funcs(funcs: Sequence[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC], *args, **kwargs) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>funcs (<a href="https://docs.python.org/3/library/typing.html#typing.Sequence" target="_blank" rel="noreferrer"><code>Sequence</code></a>[<a href="#var-lifespan-func"><code>ASYNC_LIFESPAN_FUNC</code></a> | <a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>]): </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L43" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">staticmethod</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> run_funcs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(funcs: Sequence[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 并发运行异步函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> funcs ([\`Sequence\`](https%3A//docs.python.org/3/library/typing.html#typing.Sequence)[[\`ASYNC_LIFESPAN_FUNC\`](#var-lifespan-func) | [\`PROCESS_LIFESPAN_FUNC\`](#var-process-lifespan-func)]): 函数列表</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tasks </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [func(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> is_coroutine_callable(func) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> async_wrapper(func)(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> funcs]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> asyncio.gather(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">tasks)</span></span></code></pre></div></details><h4 id="func-on-before-start-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L53" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册启动时的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_start_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="func-on-after-start-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-after-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_start(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L64" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册启动时的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_start_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="func-on-before-process-shutdown-self-func-process-lifespan-func-process-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-process-shutdown-self-func-process-lifespan-func-process-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L75" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_process_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册进程停止前的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`PROCESS_LIFESPAN_FUNC\`](#var-process-lifespan-func)): 进程生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`PROCESS_LIFESPAN_FUNC\`](#var-process-lifespan-func): 进程生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_shutdown_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="func-on-after-shutdown-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_shutdown(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-after-shutdown-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_shutdown(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L86" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册停止后的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_shutdown_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="func-on-before-process-restart-self-func-process-lifespan-func-process-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-process-restart-self-func-process-lifespan-func-process-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -&gt; PROCESS_LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="#var-process-lifespan-func"><code>PROCESS_LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L97" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_before_process_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">PROCESS_LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册进程重启前的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`PROCESS_LIFESPAN_FUNC\`](#var-process-lifespan-func)): 进程生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`PROCESS_LIFESPAN_FUNC\`](#var-process-lifespan-func): 进程生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_restart_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="func-on-after-restart-self-func-lifespan-func-lifespan-func" tabindex="-1"><em><strong>func</strong></em> <code>on_after_restart(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-after-restart-self-func-lifespan-func-lifespan-func" aria-label="Permalink to &quot;***func*** \`on_after_restart(self, func: LIFESPAN_FUNC) -&gt; LIFESPAN_FUNC\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>func (<a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>): </li></ul></blockquote><p><strong></strong>: <a href="#var-lifespan-func"><code>LIFESPAN_FUNC</code></a>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L108" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_after_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">LIFESPAN_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册重启后的函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> func ([\`LIFESPAN_FUNC\`](#var-lifespan-func)): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [\`LIFESPAN_FUNC\`](#var-lifespan-func): 生命周期函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_restart_funcs.append(func)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span></code></pre></div></details><h4 id="async-func-before-start-self-none" tabindex="-1"><em><strong>async func</strong></em> <code>before_start(self) -&gt; None</code> <a class="header-anchor" href="#async-func-before-start-self-none" aria-label="Permalink to &quot;***async func*** \`before_start(self) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L119" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> before_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 启动前钩子</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running before_start functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_start_funcs)</span></span></code></pre></div></details><h4 id="async-func-after-start-self-none" tabindex="-1"><em><strong>async func</strong></em> <code>after_start(self) -&gt; None</code> <a class="header-anchor" href="#async-func-after-start-self-none" aria-label="Permalink to &quot;***async func*** \`after_start(self) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L126" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> after_start</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 启动后钩子</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running after_start functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_start_funcs)</span></span></code></pre></div></details><h4 id="async-func-before-process-shutdown-self-args-kwargs-none" tabindex="-1"><em><strong>async func</strong></em> <code>before_process_shutdown(self, *args, **kwargs) -&gt; None</code> <a class="header-anchor" href="#async-func-before-process-shutdown-self-args-kwargs-none" aria-label="Permalink to &quot;***async func*** \`before_process_shutdown(self, *args, **kwargs) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L133" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> before_process_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 停止前钩子</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running before_shutdown functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_shutdown_funcs, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs)</span></span></code></pre></div></details><h4 id="async-func-after-shutdown-self-none" tabindex="-1"><em><strong>async func</strong></em> <code>after_shutdown(self) -&gt; None</code> <a class="header-anchor" href="#async-func-after-shutdown-self-none" aria-label="Permalink to &quot;***async func*** \`after_shutdown(self) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L140" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> after_shutdown</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 停止后钩子 未实现</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running after_shutdown functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_shutdown_funcs)</span></span></code></pre></div></details><h4 id="async-func-before-process-restart-self-args-kwargs-none" tabindex="-1"><em><strong>async func</strong></em> <code>before_process_restart(self, *args, **kwargs) -&gt; None</code> <a class="header-anchor" href="#async-func-before-process-restart-self-args-kwargs-none" aria-label="Permalink to &quot;***async func*** \`before_process_restart(self, *args, **kwargs) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L147" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> before_process_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 重启前钩子</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running before_restart functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._before_process_restart_funcs, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs)</span></span></code></pre></div></details><h4 id="async-func-after-restart-self-none" tabindex="-1"><em><strong>async func</strong></em> <code>after_restart(self) -&gt; None</code> <a class="header-anchor" href="#async-func-after-restart-self-none" aria-label="Permalink to &quot;***async func*** \`after_restart(self) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/bot/lifespan.py#L154" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> after_restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 重启后钩子 未实现</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Running after_restart functions&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_funcs(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._after_restart_funcs)</span></span></code></pre></div></details>`,79),l=[e];function p(h,k,r,o,c,d){return a(),i("div",null,l)}const E=s(t,[["render",p]]);export{u as __pageData,E as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const u=JSON.parse('{"title":"liteyuki.bot.lifespan","description":"","frontmatter":{"title":"liteyuki.bot.lifespan"},"headers":[],"relativePath":"dev/api/bot/lifespan.md","filePath":"zh/dev/api/bot/lifespan.md","lastUpdated":null}'),t={name:"dev/api/bot/lifespan.md"},e=n("",79),l=[e];function p(h,k,r,o,c,d){return a(),i("div",null,l)}const E=s(t,[["render",p]]);export{u as __pageData,E as default};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const o=JSON.parse('{"title":"liteyuki.comm.channel","description":"","frontmatter":{"title":"liteyuki.comm.channel"},"headers":[],"relativePath":"dev/api/comm/channel.md","filePath":"zh/dev/api/comm/channel.md","lastUpdated":null}'),l={name:"dev/api/comm/channel.md"},e=n("",82),t=[e];function h(p,k,r,d,c,E){return a(),i("div",null,t)}const y=s(l,[["render",h]]);export{o as __pageData,y as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o,j as e,a as c}from"./chunks/framework.C4_mTacX.js";const k=JSON.parse('{"title":"liteyuki.comm","description":"","frontmatter":{"title":"liteyuki.comm","collapsed":true},"headers":[],"relativePath":"dev/api/comm/comm.md","filePath":"zh/dev/api/comm/comm.md","lastUpdated":null}'),m={name:"dev/api/comm/comm.md"},i=e("h1",{id:"liteyuki-comm",tabindex:"-1"},[c("liteyuki.comm "),e("a",{class:"header-anchor",href:"#liteyuki-comm","aria-label":'Permalink to "liteyuki.comm"'},"")],-1),s=e("p",null,"该模块用于轻雪主进程和Nonebot子进程之间的通信 依赖关系 event -> _ storage -> channel_ rpc -> channel_, storage",-1),n=[i,s];function l(r,d,_,p,h,u){return o(),a("div",null,n)}const v=t(m,[["render",l]]);export{k as __pageData,v as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o,j as e,a as c}from"./chunks/framework.C4_mTacX.js";const k=JSON.parse('{"title":"liteyuki.comm","description":"","frontmatter":{"title":"liteyuki.comm","collapsed":true},"headers":[],"relativePath":"dev/api/comm/comm.md","filePath":"zh/dev/api/comm/comm.md","lastUpdated":null}'),m={name:"dev/api/comm/comm.md"},i=e("h1",{id:"liteyuki-comm",tabindex:"-1"},[c("liteyuki.comm "),e("a",{class:"header-anchor",href:"#liteyuki-comm","aria-label":'Permalink to "liteyuki.comm"'},"")],-1),s=e("p",null,"该模块用于轻雪主进程和Nonebot子进程之间的通信 依赖关系 event -> _ storage -> channel_ rpc -> channel_, storage",-1),n=[i,s];function l(r,d,_,p,h,u){return o(),a("div",null,n)}const v=t(m,[["render",l]]);export{k as __pageData,v as default};

View File

@ -0,0 +1 @@
import{_ as a,c as s,o as t,a9 as i}from"./chunks/framework.C4_mTacX.js";const _=JSON.parse('{"title":"liteyuki.comm.event","description":"","frontmatter":{"title":"liteyuki.comm.event"},"headers":[],"relativePath":"dev/api/comm/event.md","filePath":"zh/dev/api/comm/event.md","lastUpdated":null}'),e={name:"dev/api/comm/event.md"},n=i('<h1 id="liteyuki-comm-event" tabindex="-1">liteyuki.comm.event <a class="header-anchor" href="#liteyuki-comm-event" aria-label="Permalink to &quot;liteyuki.comm.event&quot;"></a></h1><p>本模块用于轻雪主进程和子进程之间的通信的事件类</p><h3 id="class-event" tabindex="-1"><em><strong>class</strong></em> <code>Event</code> <a class="header-anchor" href="#class-event" aria-label="Permalink to &quot;***class*** `Event`&quot;"></a></h3><h4 id="func-init-self-name-str-data-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, name: str, data: dict[str, Any])</code> <a class="header-anchor" href="#func-init-self-name-str-data-dict-str-any" aria-label="Permalink to &quot;***func*** `__init__(self, name: str, data: dict[str, Any])`&quot;"></a></h4><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/event.py#L13" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, name: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, data: dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]):</span></span>\n<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name</span></span>\n<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.data </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data</span></span></code></pre></div></details>',5),l=[n];function h(d,r,p,o,c,k){return t(),s("div",null,l)}const y=a(e,[["render",h]]);export{_ as __pageData,y as default};

View File

@ -0,0 +1 @@
import{_ as a,c as s,o as t,a9 as i}from"./chunks/framework.C4_mTacX.js";const _=JSON.parse('{"title":"liteyuki.comm.event","description":"","frontmatter":{"title":"liteyuki.comm.event"},"headers":[],"relativePath":"dev/api/comm/event.md","filePath":"zh/dev/api/comm/event.md","lastUpdated":null}'),e={name:"dev/api/comm/event.md"},n=i("",5),l=[n];function h(d,r,p,o,c,k){return t(),s("div",null,l)}const y=a(e,[["render",h]]);export{_ as __pageData,y as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o,j as e,a as i}from"./chunks/framework.C4_mTacX.js";const k=JSON.parse('{"title":"liteyuki.comm","description":"","frontmatter":{"title":"liteyuki.comm","collapsed":true},"headers":[],"relativePath":"dev/api/comm/index.md","filePath":"zh/dev/api/comm/index.md","lastUpdated":null}'),c={name:"dev/api/comm/index.md"},n=e("h1",{id:"liteyuki-comm",tabindex:"-1"},[i("liteyuki.comm "),e("a",{class:"header-anchor",href:"#liteyuki-comm","aria-label":'Permalink to "liteyuki.comm"'},"")],-1),s=e("p",null,"该模块用于轻雪主进程和Nonebot子进程之间的通信 依赖关系 event -> _ storage -> channel_ rpc -> channel_, storage",-1),l=[n,s];function r(d,m,_,p,h,u){return o(),a("div",null,l)}const x=t(c,[["render",r]]);export{k as __pageData,x as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o,j as e,a as i}from"./chunks/framework.C4_mTacX.js";const k=JSON.parse('{"title":"liteyuki.comm","description":"","frontmatter":{"title":"liteyuki.comm","collapsed":true},"headers":[],"relativePath":"dev/api/comm/index.md","filePath":"zh/dev/api/comm/index.md","lastUpdated":null}'),c={name:"dev/api/comm/index.md"},n=e("h1",{id:"liteyuki-comm",tabindex:"-1"},[i("liteyuki.comm "),e("a",{class:"header-anchor",href:"#liteyuki-comm","aria-label":'Permalink to "liteyuki.comm"'},"")],-1),s=e("p",null,"该模块用于轻雪主进程和Nonebot子进程之间的通信 依赖关系 event -> _ storage -> channel_ rpc -> channel_, storage",-1),l=[n,s];function r(d,m,_,p,h,u){return o(),a("div",null,l)}const x=t(c,[["render",r]]);export{k as __pageData,x as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as t}from"./chunks/framework.C4_mTacX.js";const u=JSON.parse('{"title":"liteyuki.comm.rpc","description":"","frontmatter":{"title":"liteyuki.comm.rpc"},"headers":[],"relativePath":"dev/api/comm/rpc.md","filePath":"zh/dev/api/comm/rpc.md","lastUpdated":null}'),n={name:"dev/api/comm/rpc.md"},e=t('<h1 id="liteyuki-comm-rpc" tabindex="-1">liteyuki.comm.rpc <a class="header-anchor" href="#liteyuki-comm-rpc" aria-label="Permalink to &quot;liteyuki.comm.rpc&quot;"></a></h1><p>本模块用于实现RPC(基于IPC)通信</p><h3 id="class-rpc" tabindex="-1"><em><strong>class</strong></em> <code>RPC</code> <a class="header-anchor" href="#class-rpc" aria-label="Permalink to &quot;***class*** `RPC`&quot;"></a></h3><h4 id="func-init-self-on-calling-on-calling-func-none" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, on_calling: ON_CALLING_FUNC) -&gt; None</code> <a class="header-anchor" href="#func-init-self-on-calling-on-calling-func-none" aria-label="Permalink to &quot;***func*** `__init__(self, on_calling: ON_CALLING_FUNC) -&gt; None`&quot;"></a></h4><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/rpc.py#L18" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, on_calling: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">ON_CALLING_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>\n<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.on_calling </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> on_calling</span></span></code></pre></div></details><h4 id="func-call-self-args-tuple-kwargs-dict-any" tabindex="-1"><em><strong>func</strong></em> <code>call(self, args: tuple, kwargs: dict) -&gt; Any</code> <a class="header-anchor" href="#func-call-self-args-tuple-kwargs-dict-any" aria-label="Permalink to &quot;***func*** `call(self, args: tuple, kwargs: dict) -&gt; Any`&quot;"></a></h4><p><strong>说明</strong>: 调用</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/rpc.py#L21" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> call</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, args: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">tuple</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, kwargs: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">dict</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Any:</span></span>\n<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>\n<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 调用</span></span>\n<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.on_calling(args, kwargs)</span></span></code></pre></div></details>',8),l=[e];function p(h,c,r,o,k,d){return a(),i("div",null,l)}const m=s(n,[["render",p]]);export{u as __pageData,m as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as t}from"./chunks/framework.C4_mTacX.js";const u=JSON.parse('{"title":"liteyuki.comm.rpc","description":"","frontmatter":{"title":"liteyuki.comm.rpc"},"headers":[],"relativePath":"dev/api/comm/rpc.md","filePath":"zh/dev/api/comm/rpc.md","lastUpdated":null}'),n={name:"dev/api/comm/rpc.md"},e=t("",8),l=[e];function p(h,c,r,o,k,d){return a(),i("div",null,l)}const m=s(n,[["render",p]]);export{u as __pageData,m as default};

View File

@ -0,0 +1,26 @@
import{_ as s,c as a,o as i,a9 as n}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.comm.socks_channel","description":"","frontmatter":{"title":"liteyuki.comm.socks_channel"},"headers":[],"relativePath":"dev/api/comm/socks_channel.md","filePath":"zh/dev/api/comm/socks_channel.md","lastUpdated":null}'),e={name:"dev/api/comm/socks_channel.md"},t=n(`<h1 id="liteyuki-comm-socks-channel" tabindex="-1">liteyuki.comm.socks_channel <a class="header-anchor" href="#liteyuki-comm-socks-channel" aria-label="Permalink to &quot;liteyuki.comm.socks_channel&quot;"></a></h1><p>基于socket的通道</p><h3 id="class-sockschannel" tabindex="-1"><em><strong>class</strong></em> <code>SocksChannel</code> <a class="header-anchor" href="#class-sockschannel" aria-label="Permalink to &quot;***class*** \`SocksChannel\`&quot;"></a></h3><h4 id="func-init-self-name-str" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, name: str)</code> <a class="header-anchor" href="#func-init-self-name-str" aria-label="Permalink to &quot;***func*** \`__init__(self, name: str)\`&quot;"></a></h4><p><strong>说明</strong>: 初始化通道</p><p><strong>参数</strong>:</p><blockquote><ul><li>name: 通道ID</li></ul></blockquote><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/socks_channel.py#L13" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, name: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 初始化通道</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name: 通道ID</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._conn_send </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._conn_recv </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._closed </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> False</span></span></code></pre></div></details><h4 id="func-send-self-data" tabindex="-1"><em><strong>func</strong></em> <code>send(self, data)</code> <a class="header-anchor" href="#func-send-self-data" aria-label="Permalink to &quot;***func*** \`send(self, data)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>data: </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/socks_channel.py#L25" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> send</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, data):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 发送数据</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> data: 数据</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> pass</span></span></code></pre></div></details><h4 id="func-receive-self" tabindex="-1"><em><strong>func</strong></em> <code>receive(self)</code> <a class="header-anchor" href="#func-receive-self" aria-label="Permalink to &quot;***func*** \`receive(self)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>: data: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/socks_channel.py#L34" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> receive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 接收数据</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> data: 数据</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> pass</span></span></code></pre></div></details><h4 id="func-close-self" tabindex="-1"><em><strong>func</strong></em> <code>close(self)</code> <a class="header-anchor" href="#func-close-self" aria-label="Permalink to &quot;***func*** \`close(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/socks_channel.py#L43" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> close</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 关闭通道</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> pass</span></span></code></pre></div></details>`,20),l=[t];function h(p,k,o,c,r,d){return i(),a("div",null,l)}const y=s(e,[["render",h]]);export{g as __pageData,y as default};

View File

@ -0,0 +1 @@
import{_ as s,c as a,o as i,a9 as n}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.comm.socks_channel","description":"","frontmatter":{"title":"liteyuki.comm.socks_channel"},"headers":[],"relativePath":"dev/api/comm/socks_channel.md","filePath":"zh/dev/api/comm/socks_channel.md","lastUpdated":null}'),e={name:"dev/api/comm/socks_channel.md"},t=n("",20),l=[t];function h(p,k,o,c,r,d){return i(),a("div",null,l)}const y=s(e,[["render",h]]);export{g as __pageData,y as default};

View File

@ -0,0 +1,144 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const c=JSON.parse('{"title":"liteyuki.comm.storage","description":"","frontmatter":{"title":"liteyuki.comm.storage"},"headers":[],"relativePath":"dev/api/comm/storage.md","filePath":"zh/dev/api/comm/storage.md","lastUpdated":null}'),t={name:"dev/api/comm/storage.md"},e=n(`<h1 id="liteyuki-comm-storage" tabindex="-1">liteyuki.comm.storage <a class="header-anchor" href="#liteyuki-comm-storage" aria-label="Permalink to &quot;liteyuki.comm.storage&quot;"></a></h1><p>共享内存模块。类似于redis但是更加轻量级并且线程安全</p><h3 id="var-on-main-subscriber-receive-funcs" tabindex="-1">var <code>_on_main_subscriber_receive_funcs</code> <a class="header-anchor" href="#var-on-main-subscriber-receive-funcs" aria-label="Permalink to &quot;var \`_on_main_subscriber_receive_funcs\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 主进程订阅者接收函数</p></li><li><p><strong>类型</strong>: <code>dict[str, list[ASYNC_ON_RECEIVE_FUNC]]</code></p></li><li><p><strong>默认值</strong>: <code>{}</code></p></li></ul><h3 id="var-on-sub-subscriber-receive-funcs" tabindex="-1">var <code>_on_sub_subscriber_receive_funcs</code> <a class="header-anchor" href="#var-on-sub-subscriber-receive-funcs" aria-label="Permalink to &quot;var \`_on_sub_subscriber_receive_funcs\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 子进程订阅者接收函数</p></li><li><p><strong>类型</strong>: <code>dict[str, list[ASYNC_ON_RECEIVE_FUNC]]</code></p></li><li><p><strong>默认值</strong>: <code>{}</code></p></li></ul><h3 id="class-keyvaluestore" tabindex="-1"><em><strong>class</strong></em> <code>KeyValueStore</code> <a class="header-anchor" href="#class-keyvaluestore" aria-label="Permalink to &quot;***class*** \`KeyValueStore\`&quot;"></a></h3><h4 id="func-init-self" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self)</code> <a class="header-anchor" href="#func-init-self" aria-label="Permalink to &quot;***func*** \`__init__(self)\`&quot;"></a></h4><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L35" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._store </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {}</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.active_chan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Channel[tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Optional[dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]]]](</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;shared_memory-active&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.passive_chan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Channel[tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Optional[dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]]]](</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;shared_memory-passive&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.publish_channel </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Channel[tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]](</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;shared_memory-publish&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.is_main_receive_loop_running </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> False</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.is_sub_receive_loop_running </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> False</span></span></code></pre></div></details><h4 id="func-set-self-key-str-value-any-none" tabindex="-1"><em><strong>func</strong></em> <code>set(self, key: str, value: Any) -&gt; None</code> <a class="header-anchor" href="#func-set-self-key-str-value-any-none" aria-label="Permalink to &quot;***func*** \`set(self, key: str, value: Any) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>key: </li><li>value: </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L45" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> set</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, key: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, value: Any) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 设置键值对</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key: </span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> value: </span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> lock </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _get_lock(key)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> with</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> lock:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._store[key] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> value</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.passive_chan.send((</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;set&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;key&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: key, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;value&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: value}))</span></span></code></pre></div></details><h4 id="func-get-self-key-str-default-optional-any-none-optional-any" tabindex="-1"><em><strong>func</strong></em> <code>get(self, key: str, default: Optional[Any] = None) -&gt; Optional[Any]</code> <a class="header-anchor" href="#func-get-self-key-str-default-optional-any-none-optional-any" aria-label="Permalink to &quot;***func*** \`get(self, key: str, default: Optional[Any] = None) -&gt; Optional[Any]\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>key: </li><li>default: </li></ul></blockquote><p><strong></strong>: Any: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L69" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, key: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, default: Optional[Any]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Optional[Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取键值对</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key: </span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> default: 默认值</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Any: </span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> lock </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _get_lock(key)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> with</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> lock:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._store.get(key, default)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> recv_chan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Channel[Optional[Any]](</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;recv_chan&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.passive_chan.send((</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;get&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;key&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: key, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;default&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: default, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;recv_chan&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: recv_chan}))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> recv_chan.receive()</span></span></code></pre></div></details><h4 id="func-delete-self-key-str-ignore-key-error-bool-true-none" tabindex="-1"><em><strong>func</strong></em> <code>delete(self, key: str, ignore_key_error: bool = True) -&gt; None</code> <a class="header-anchor" href="#func-delete-self-key-str-ignore-key-error-bool-true-none" aria-label="Permalink to &quot;***func*** \`delete(self, key: str, ignore_key_error: bool = True) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>key: </li><li>ignore_key_error: </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L98" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> delete</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, key: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, ignore_key_error: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 删除键值对</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key: </span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ignore_key_error: 是否忽略键不存在的错误</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> lock </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _get_lock(key)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> with</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> lock:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._store:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> del</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._store[key]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> del</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _locks[key]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> KeyError</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> e:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ignore_key_error:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> raise</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> e</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.passive_chan.send((</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;delete&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;key&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: key}))</span></span></code></pre></div></details><h4 id="func-get-all-self-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>get_all(self) -&gt; dict[str, Any]</code> <a class="header-anchor" href="#func-get-all-self-dict-str-any" aria-label="Permalink to &quot;***func*** \`get_all(self) -&gt; dict[str, Any]\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>: dict[str, Any]: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L128" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_all</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取所有键值对</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dict[str, Any]: 键值对</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._store</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> recv_chan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Channel[dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]](</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;recv_chan&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.passive_chan.send((</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;get_all&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;recv_chan&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: recv_chan}))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> recv_chan.receive()</span></span></code></pre></div></details><h4 id="func-publish-self-channel-str-data-any-none" tabindex="-1"><em><strong>func</strong></em> <code>publish(self, channel_: str, data: Any) -&gt; None</code> <a class="header-anchor" href="#func-publish-self-channel-str-data-any-none" aria-label="Permalink to &quot;***func*** \`publish(self, channel_: str, data: Any) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>channel_: </li><li>data: </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L148" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> publish</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, channel_: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, data: Any) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 发布消息</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> channel_: 频道</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> data: 数据</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.active_chan.send((</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;publish&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;channel&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: channel_, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;data&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: data}))</span></span></code></pre></div></details><h4 id="func-on-subscriber-receive-self-channel-str-callable-on-receive-func-on-receive-func" tabindex="-1"><em><strong>func</strong></em> <code>on_subscriber_receive(self, channel_: str) -&gt; Callable[[ON_RECEIVE_FUNC], ON_RECEIVE_FUNC]</code> <a class="header-anchor" href="#func-on-subscriber-receive-self-channel-str-callable-on-receive-func-on-receive-func" aria-label="Permalink to &quot;***func*** \`on_subscriber_receive(self, channel_: str) -&gt; Callable[[ON_RECEIVE_FUNC], ON_RECEIVE_FUNC]\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>channel_: </li></ul></blockquote><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L167" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_subscriber_receive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, channel_: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Callable[[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">ON_RECEIVE_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">ON_RECEIVE_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 订阅者接收消息时的回调</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> channel_: 频道</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 装饰器</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> raise</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> RuntimeError</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Cannot subscribe in sub process.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> decorator</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">ON_RECEIVE_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">ON_RECEIVE_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> wrapper</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data: Any):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> is_coroutine_callable(func):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func(data)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func(data)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> channel_ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _on_main_subscriber_receive_funcs:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _on_main_subscriber_receive_funcs[channel_] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _on_main_subscriber_receive_funcs[channel_].append(wrapper)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> channel_ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _on_sub_subscriber_receive_funcs:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _on_sub_subscriber_receive_funcs[channel_] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _on_sub_subscriber_receive_funcs[channel_].append(wrapper)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> wrapper</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> decorator</span></span></code></pre></div></details><p><a href="https://docs.python.org/3/library/functions.html#staticmethod" target="_blank" rel="noreferrer"><code>@staticmethod</code></a></p><h4 id="async-func-run-subscriber-receive-funcs-channel-str-data-any" tabindex="-1"><em><strong>async func</strong></em> <code>run_subscriber_receive_funcs(channel_: str, data: Any)</code> <a class="header-anchor" href="#async-func-run-subscriber-receive-funcs-channel-str-data-any" aria-label="Permalink to &quot;***async func*** \`run_subscriber_receive_funcs(channel_: str, data: Any)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>channel_: </li><li>data: </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L199" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">staticmethod</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> run_subscriber_receive_funcs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(channel_: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, data: Any):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 运行订阅者接收函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> channel_: 频道</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> data: 数据</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [asyncio.create_task(func(data)) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _on_main_subscriber_receive_funcs[channel_]]</span></span></code></pre></div></details><h4 id="async-func-start-receive-loop-self" tabindex="-1"><em><strong>async func</strong></em> <code>start_receive_loop(self)</code> <a class="header-anchor" href="#async-func-start-receive-loop-self" aria-label="Permalink to &quot;***async func*** \`start_receive_loop(self)\`&quot;"></a></h4><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L208" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> start_receive_loop</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 启动发布订阅接收器循环在主进程中运行若有子进程订阅则推送给子进程</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> IS_MAIN_PROCESS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> raise</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> RuntimeError</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Cannot start receive loop in sub process.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> while</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.active_chan.async_receive()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;publish&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.run_subscriber_receive_funcs(data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;channel&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;data&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">])</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.publish_channel.send(data)</span></span></code></pre></div></details><h3 id="class-globalkeyvaluestore" tabindex="-1"><em><strong>class</strong></em> <code>GlobalKeyValueStore</code> <a class="header-anchor" href="#class-globalkeyvaluestore" aria-label="Permalink to &quot;***class*** \`GlobalKeyValueStore\`&quot;"></a></h3><p><a href="https://docs.python.org/3/library/functions.html#classmethod" target="_blank" rel="noreferrer"><code>@classmethod</code></a></p><h4 id="func-get-instance-cls" tabindex="-1"><em><strong>func</strong></em> <code>get_instance(cls)</code> <a class="header-anchor" href="#func-get-instance-cls" aria-label="Permalink to &quot;***func*** \`get_instance(cls)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L229" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">classmethod</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_instance</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(cls):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> cls</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._instance </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> with</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> cls</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._lock:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> cls</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._instance </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> cls</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._instance </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> KeyValueStore()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> cls</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._instance</span></span></code></pre></div></details><h4 id="attr-instance-none" tabindex="-1"><em><strong>attr</strong></em> <code>_instance = None</code> <a class="header-anchor" href="#attr-instance-none" aria-label="Permalink to &quot;***attr*** \`_instance = None\`&quot;"></a></h4><h4 id="attr-lock-threading-lock" tabindex="-1"><em><strong>attr</strong></em> <code>_lock = threading.Lock()</code> <a class="header-anchor" href="#attr-lock-threading-lock" aria-label="Permalink to &quot;***attr*** \`_lock = threading.Lock()\`&quot;"></a></h4><h3 id="var-shared-memory" tabindex="-1">var <code>shared_memory</code> <a class="header-anchor" href="#var-shared-memory" aria-label="Permalink to &quot;var \`shared_memory\`&quot;"></a></h3><ul><li><p><strong></strong>: </p></li><li><p><strong></strong>: <code>KeyValueStore</code></p></li><li><p><strong></strong>: <code>GlobalKeyValueStore.get_instance()</code></p></li></ul><h3 id="var-ref-count" tabindex="-1">var <code>_ref_count</code> <a class="header-anchor" href="#var-ref-count" aria-label="Permalink to &quot;var \`_ref_count\`&quot;"></a></h3><ul><li><p><strong></strong>: import , </p></li><li><p><strong></strong>: <code>0</code></p></li></ul><p><code>@shared_memory.passive_chan.on_receive(lambda d: d[0] == &#39;get&#39;)</code></p><h3 id="func-on-get-data-tuple-str-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>on_get(data: tuple[str, dict[str, Any]])</code> <a class="header-anchor" href="#func-on-get-data-tuple-str-dict-str-any" aria-label="Permalink to &quot;***func*** \`on_get(data: tuple[str, dict[str, Any]])\`&quot;"></a></h3><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L242" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@shared_memory.passive_chan.on_receive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">lambda</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> d: d[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;get&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_get</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data: tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]]):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;key&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> default </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;default&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> recv_chan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;recv_chan&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> recv_chan.send(shared_memory.get(key, default))</span></span></code></pre></div></details><p><code>@shared_memory.passive_chan.on_receive(lambda d: d[0] == &#39;set&#39;)</code></p><h3 id="func-on-set-data-tuple-str-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>on_set(data: tuple[str, dict[str, Any]])</code> <a class="header-anchor" href="#func-on-set-data-tuple-str-dict-str-any" aria-label="Permalink to &quot;***func*** \`on_set(data: tuple[str, dict[str, Any]])\`&quot;"></a></h3><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L250" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@shared_memory.passive_chan.on_receive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">lambda</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> d: d[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;set&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_set</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data: tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]]):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;key&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> value </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;value&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> shared_memory.set(key, value)</span></span></code></pre></div></details><p><code>@shared_memory.passive_chan.on_receive(lambda d: d[0] == &#39;delete&#39;)</code></p><h3 id="func-on-delete-data-tuple-str-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>on_delete(data: tuple[str, dict[str, Any]])</code> <a class="header-anchor" href="#func-on-delete-data-tuple-str-dict-str-any" aria-label="Permalink to &quot;***func*** \`on_delete(data: tuple[str, dict[str, Any]])\`&quot;"></a></h3><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L257" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@shared_memory.passive_chan.on_receive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">lambda</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> d: d[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;delete&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_delete</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data: tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]]):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> key </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;key&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> shared_memory.delete(key)</span></span></code></pre></div></details><p><code>@shared_memory.passive_chan.on_receive(lambda d: d[0] == &#39;get_all&#39;)</code></p><h3 id="func-on-get-all-data-tuple-str-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>on_get_all(data: tuple[str, dict[str, Any]])</code> <a class="header-anchor" href="#func-on-get-all-data-tuple-str-dict-str-any" aria-label="Permalink to &quot;***func*** \`on_get_all(data: tuple[str, dict[str, Any]])\`&quot;"></a></h3><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/comm/storage.py#L263" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@shared_memory.passive_chan.on_receive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">lambda</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> d: d[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;get_all&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_get_all</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(data: tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]]):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> recv_chan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">][</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;recv_chan&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> recv_chan.send(shared_memory.get_all())</span></span></code></pre></div></details>`,71),l=[e];function h(k,p,r,d,E,g){return a(),i("div",null,l)}const o=s(t,[["render",h]]);export{c as __pageData,o as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const c=JSON.parse('{"title":"liteyuki.comm.storage","description":"","frontmatter":{"title":"liteyuki.comm.storage"},"headers":[],"relativePath":"dev/api/comm/storage.md","filePath":"zh/dev/api/comm/storage.md","lastUpdated":null}'),t={name:"dev/api/comm/storage.md"},e=n("",71),l=[e];function h(k,p,r,d,E,g){return a(),i("div",null,l)}const o=s(t,[["render",h]]);export{c as __pageData,o as default};

View File

@ -0,0 +1,77 @@
import{_ as i,c as a,o as n,a9 as s,j as t}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.config","description":"","frontmatter":{"title":"liteyuki.config"},"headers":[],"relativePath":"dev/api/config.md","filePath":"zh/dev/api/config.md","lastUpdated":null}'),l={name:"dev/api/config.md"},h=s('<h1 id="liteyuki-config" tabindex="-1">liteyuki.config <a class="header-anchor" href="#liteyuki-config" aria-label="Permalink to &quot;liteyuki.config&quot;"></a></h1><p>该模块用于常用配置文件的加载 多配置文件编写原则:</p><ol><li>尽量不要冲突: 一个键不要多次出现</li><li>分工明确: 每个配置文件给一个或一类服务提供配置</li><li>扁平化编写: 配置文件尽量扁平化,不要出现过多的嵌套</li><li>注意冲突时的优先级: 项目目录下的配置文件优先级高于config目录下的配置文件</li><li>请不要将需要动态加载的内容写入配置文件,你应该使用其他储存方式</li></ol><h3 id="func-flat-config-config-dict-str-any-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>flat_config(config: dict[str, Any]) -&gt; dict[str, Any]</code> <a class="header-anchor" href="#func-flat-config-config-dict-str-any-dict-str-any" aria-label="Permalink to &quot;***func*** `flat_config(config: dict[str, Any]) -&gt; dict[str, Any]`&quot;"></a></h3><p><strong>说明</strong>: 扁平化配置文件</p>',5),k=t("p",{"a.b.c:":"",1:""},"{a:{b:{c:1}}} ->",-1),p=s(`<p><strong>参数</strong>:</p><blockquote><ul><li>config: 配置项目</li></ul></blockquote><p><strong>返回</strong>: 扁平化后的配置文件,但也包含原有的键值对</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/config.py#L24" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> flat_config</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(config: dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]) -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 扁平化配置文件</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> {a:{b:{c:1}}} -&gt; {&quot;a.b.c&quot;: 1}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> config: 配置项目</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 扁平化后的配置文件但也包含原有的键值对</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> new_config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> copy.deepcopy(config)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> key, value </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.items():</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> isinstance</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(value, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">dict</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> k, v </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> flat_config(value).items():</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> new_config[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">key</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">k</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> v</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> new_config</span></span></code></pre></div></details><h3 id="func-load-from-yaml-file-str-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>load_from_yaml(file_: str) -&gt; dict[str, Any]</code> <a class="header-anchor" href="#func-load-from-yaml-file-str-dict-str-any" aria-label="Permalink to &quot;***func*** \`load_from_yaml(file_: str) -&gt; dict[str, Any]\`&quot;"></a></h3><p><strong></strong>: Load config from yaml file</p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/config.py#L43" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> load_from_yaml</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(file_: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Load config from yaml file</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Loading YAML config from </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">file_</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> yaml.safe_load(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">open</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(file_, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;r&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">encoding</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;utf-8&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> flat_config(config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {})</span></span></code></pre></div></details><h3 id="func-load-from-json-file-str-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>load_from_json(file_: str) -&gt; dict[str, Any]</code> <a class="header-anchor" href="#func-load-from-json-file-str-dict-str-any" aria-label="Permalink to &quot;***func*** \`load_from_json(file_: str) -&gt; dict[str, Any]\`&quot;"></a></h3><p><strong></strong>: Load config from json file</p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/config.py#L53" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> load_from_json</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(file_: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Load config from json file</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Loading JSON config from </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">file_</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> json.load(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">open</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(file_, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;r&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">encoding</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;utf-8&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> flat_config(config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {})</span></span></code></pre></div></details><h3 id="func-load-from-toml-file-str-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>load_from_toml(file_: str) -&gt; dict[str, Any]</code> <a class="header-anchor" href="#func-load-from-toml-file-str-dict-str-any" aria-label="Permalink to &quot;***func*** \`load_from_toml(file_: str) -&gt; dict[str, Any]\`&quot;"></a></h3><p><strong></strong>: Load config from toml file</p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/config.py#L62" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> load_from_toml</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(file_: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Load config from toml file</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Loading TOML config from </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">file_</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> toml.load(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">open</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(file_, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;r&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">encoding</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;utf-8&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> flat_config(config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {})</span></span></code></pre></div></details><h3 id="func-load-from-files-files-str-no-warning-bool-false-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>load_from_files(*files: str, *, no_warning: bool = False) -&gt; dict[str, Any]</code> <a class="header-anchor" href="#func-load-from-files-files-str-no-warning-bool-false-dict-str-any" aria-label="Permalink to &quot;***func*** \`load_from_files(*files: str, *, no_warning: bool = False) -&gt; dict[str, Any]\`&quot;"></a></h3><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/config.py#L71" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> load_from_files</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">files: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, no_warning: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">False</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 从指定文件加载配置项会自动识别文件格式</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 默认执行扁平化选项</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {}</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> file</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> files:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.path.exists(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.endswith((</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.yaml&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;yml&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.update(load_from_yaml(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.endswith(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.json&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.update(load_from_json(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.endswith(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.toml&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.update(load_from_toml(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> no_warning:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Unsupported config file format: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">file</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> no_warning:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Config file not found: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">file</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config</span></span></code></pre></div></details><h3 id="func-load-configs-from-dirs-directories-str-no-waring-bool-false-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>load_configs_from_dirs(*directories: str, *, no_waring: bool = False) -&gt; dict[str, Any]</code> <a class="header-anchor" href="#func-load-configs-from-dirs-directories-str-no-waring-bool-false-dict-str-any" aria-label="Permalink to &quot;***func*** \`load_configs_from_dirs(*directories: str, *, no_waring: bool = False) -&gt; dict[str, Any]\`&quot;"></a></h3><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/config.py#L94" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> load_configs_from_dirs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">directories: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, no_waring: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">False</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 从目录下加载配置文件不递归</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 按照读取文件的优先级反向覆盖</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 默认执行扁平化选项</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {}</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> directory </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> directories:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.path.exists(directory):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> no_waring:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Directory not found: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">directory</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> continue</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> file</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.listdir(directory):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;"> file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.endswith(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">_SUPPORTED_CONFIG_FORMATS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.update(load_from_files(os.path.join(directory, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">), </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">no_warning</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">no_waring))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config</span></span></code></pre></div></details><h3 id="func-load-config-in-default-no-waring-bool-false-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>load_config_in_default(no_waring: bool = False) -&gt; dict[str, Any]</code> <a class="header-anchor" href="#func-load-config-in-default-no-waring-bool-false-dict-str-any" aria-label="Permalink to &quot;***func*** \`load_config_in_default(no_waring: bool = False) -&gt; dict[str, Any]\`&quot;"></a></h3><p><strong></strong>: config.*config </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/config.py#L116" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> load_config_in_default</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(no_waring: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">False</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 从一个标准的轻雪项目加载配置文件</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 项目目录下的config.*和config目录下的所有配置文件</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 项目目录下的配置文件优先</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_configs_from_dirs(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;config&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">no_waring</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">no_waring)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.update(load_from_files(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;config.yaml&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;config.toml&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;config.json&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;config.yml&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">no_warning</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">no_waring))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config</span></span></code></pre></div></details>`,22),e=[h,k,p];function r(d,g,E,o,y,F){return n(),a("div",null,e)}const u=i(l,[["render",r]]);export{f as __pageData,u as default};

View File

@ -0,0 +1 @@
import{_ as i,c as a,o as n,a9 as s,j as t}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.config","description":"","frontmatter":{"title":"liteyuki.config"},"headers":[],"relativePath":"dev/api/config.md","filePath":"zh/dev/api/config.md","lastUpdated":null}'),l={name:"dev/api/config.md"},h=s("",5),k=t("p",{"a.b.c:":"",1:""},"{a:{b:{c:1}}} ->",-1),p=s("",22),e=[h,k,p];function r(d,g,E,o,y,F){return n(),a("div",null,e)}const u=i(l,[["render",r]]);export{f as __pageData,u as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o,j as e,a as r}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.core","description":"","frontmatter":{"title":"liteyuki.core","collapsed":true},"headers":[],"relativePath":"dev/api/core/core.md","filePath":"zh/dev/api/core/core.md","lastUpdated":null}'),c={name:"dev/api/core/core.md"},i=e("h1",{id:"liteyuki-core",tabindex:"-1"},[r("liteyuki.core "),e("a",{class:"header-anchor",href:"#liteyuki-core","aria-label":'Permalink to "liteyuki.core"'},"")],-1),s=[i];function l(d,n,p,_,u,h){return o(),a("div",null,s)}const k=t(c,[["render",l]]);export{f as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o,j as e,a as r}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.core","description":"","frontmatter":{"title":"liteyuki.core","collapsed":true},"headers":[],"relativePath":"dev/api/core/core.md","filePath":"zh/dev/api/core/core.md","lastUpdated":null}'),c={name:"dev/api/core/core.md"},i=e("h1",{id:"liteyuki-core",tabindex:"-1"},[r("liteyuki.core "),e("a",{class:"header-anchor",href:"#liteyuki-core","aria-label":'Permalink to "liteyuki.core"'},"")],-1),s=[i];function l(d,n,p,_,u,h){return o(),a("div",null,s)}const k=t(c,[["render",l]]);export{f as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o as i,j as e,a as o}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.core","description":"","frontmatter":{"title":"liteyuki.core","collapsed":true},"headers":[],"relativePath":"dev/api/core/index.md","filePath":"zh/dev/api/core/index.md","lastUpdated":null}'),r={name:"dev/api/core/index.md"},c=e("h1",{id:"liteyuki-core",tabindex:"-1"},[o("liteyuki.core "),e("a",{class:"header-anchor",href:"#liteyuki-core","aria-label":'Permalink to "liteyuki.core"'},"")],-1),d=[c];function s(n,l,p,_,u,h){return i(),a("div",null,d)}const k=t(r,[["render",s]]);export{f as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o as i,j as e,a as o}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.core","description":"","frontmatter":{"title":"liteyuki.core","collapsed":true},"headers":[],"relativePath":"dev/api/core/index.md","filePath":"zh/dev/api/core/index.md","lastUpdated":null}'),r={name:"dev/api/core/index.md"},c=e("h1",{id:"liteyuki-core",tabindex:"-1"},[o("liteyuki.core "),e("a",{class:"header-anchor",href:"#liteyuki-core","aria-label":'Permalink to "liteyuki.core"'},"")],-1),d=[c];function s(n,l,p,_,u,h){return i(),a("div",null,d)}const k=t(r,[["render",s]]);export{f as __pageData,k as default};

View File

@ -0,0 +1,61 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.core.manager","description":"","frontmatter":{"title":"liteyuki.core.manager"},"headers":[],"relativePath":"dev/api/core/manager.md","filePath":"zh/dev/api/core/manager.md","lastUpdated":null}'),e={name:"dev/api/core/manager.md"},t=n(`<h1 id="liteyuki-core-manager" tabindex="-1">liteyuki.core.manager <a class="header-anchor" href="#liteyuki-core-manager" aria-label="Permalink to &quot;liteyuki.core.manager&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/7/27 上午11:12 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : manager.py @Software: PyCharm</p><h3 id="class-channeldeliver" tabindex="-1"><em><strong>class</strong></em> <code>ChannelDeliver</code> <a class="header-anchor" href="#class-channeldeliver" aria-label="Permalink to &quot;***class*** \`ChannelDeliver\`&quot;"></a></h3><h4 id="func-init-self-active-channel-any-passive-channel-any-channel-deliver-active-channel-channel-any-channel-deliver-passive-channel-tuple-str-dict-publish-channel-tuple-str-any" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, active: Channel[Any], passive: Channel[Any], channel_deliver_active: Channel[Channel[Any]], channel_deliver_passive: Channel[tuple[str, dict]], publish: Channel[tuple[str, Any]])</code> <a class="header-anchor" href="#func-init-self-active-channel-any-passive-channel-any-channel-deliver-active-channel-channel-any-channel-deliver-passive-channel-tuple-str-dict-publish-channel-tuple-str-any" aria-label="Permalink to &quot;***func*** \`__init__(self, active: Channel[Any], passive: Channel[Any], channel_deliver_active: Channel[Channel[Any]], channel_deliver_passive: Channel[tuple[str, dict]], publish: Channel[tuple[str, Any]])\`&quot;"></a></h4><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/core/manager.py#L44" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, active: Channel[Any], passive: Channel[Any], channel_deliver_active: Channel[Channel[Any]], channel_deliver_passive: Channel[tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">dict</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]], publish: Channel[tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]]):</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.active </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> active</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.passive </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> passive</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.channel_deliver_active </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> channel_deliver_active</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.channel_deliver_passive </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> channel_deliver_passive</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.publish </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> publish</span></span></code></pre></div></details><h3 id="class-processmanager" tabindex="-1"><em><strong>class</strong></em> <code>ProcessManager</code> <a class="header-anchor" href="#class-processmanager" aria-label="Permalink to &quot;***class*** \`ProcessManager\`&quot;"></a></h3><h4 id="func-init-self-lifespan-lifespan" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, lifespan: Lifespan)</code> <a class="header-anchor" href="#func-init-self-lifespan-lifespan" aria-label="Permalink to &quot;***func*** \`__init__(self, lifespan: Lifespan)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/core/manager.py#L87" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, lifespan: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Lifespan&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.lifespan </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> lifespan</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.targets: dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, tuple[Callable, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">tuple</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">dict</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {}</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.processes: dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Process] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {}</span></span></code></pre></div></details><h4 id="func-start-all-self" tabindex="-1"><em><strong>func</strong></em> <code>start_all(self)</code> <a class="header-anchor" href="#func-start-all-self" aria-label="Permalink to &quot;***func*** \`start_all(self)\`&quot;"></a></h4><p><strong></strong>: asyncio task</p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/core/manager.py#L128" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> start_all</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 对外启动方法启动所有进程创建asyncio task</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.targets:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Starting process </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> threading.Thread(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">target</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">._run_process, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">args</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(name,), </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">daemon</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).start()</span></span></code></pre></div></details><h4 id="func-add-target-self-name-str-target-target-func-args-tuple-kwargs-none" tabindex="-1"><em><strong>func</strong></em> <code>add_target(self, name: str, target: TARGET_FUNC, args: tuple = (), kwargs = None)</code> <a class="header-anchor" href="#func-add-target-self-name-str-target-target-func-args-tuple-kwargs-none" aria-label="Permalink to &quot;***func*** \`add_target(self, name: str, target: TARGET_FUNC, args: tuple = (), kwargs = None)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>name: </li><li>target: </li><li>args: </li><li>kwargs: chan_activechan_passive</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/core/manager.py#L138" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> add_target</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, name: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, target: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">TARGET_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, args: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">tuple</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(), kwargs</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 添加进程</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name: 进程名用于获取和唯一标识</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> target: 进程函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> args: 进程函数参数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kwargs: 进程函数关键字参数通常会默认传入chan_active和chan_passive</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> kwargs </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> kwargs </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_active: Channel </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Channel(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">-active&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> chan_passive: Channel </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Channel(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">-passive&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> channel_deliver </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ChannelDeliver(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">active</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">chan_active, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">passive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">chan_passive, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">channel_deliver_active</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">channel_deliver_active_channel, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">channel_deliver_passive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">channel_deliver_passive_channel, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">publish</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">publish_channel)</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.targets[name] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (_delivery_channel_wrapper, (target, channel_deliver, shared_memory, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args), kwargs)</span></span></code></pre></div></details><h4 id="func-join-all-self" tabindex="-1"><em><strong>func</strong></em> <code>join_all(self)</code> <a class="header-anchor" href="#func-join-all-self" aria-label="Permalink to &quot;***func*** \`join_all(self)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/core/manager.py#L163" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> join_all</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name, process </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.targets:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> process.join()</span></span></code></pre></div></details><h4 id="func-terminate-self-name-str" tabindex="-1"><em><strong>func</strong></em> <code>terminate(self, name: str)</code> <a class="header-anchor" href="#func-terminate-self-name-str" aria-label="Permalink to &quot;***func*** \`terminate(self, name: str)\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>name:</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/core/manager.py#L167" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> terminate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, name: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 终止进程并从进程字典中删除</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.processes:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Process </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> not found.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> process </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.processes[name]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> process.terminate()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> process.join(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">TIMEOUT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> process.is_alive():</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> process.kill()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.success(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Process </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> terminated.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h4 id="func-terminate-all-self" tabindex="-1"><em><strong>func</strong></em> <code>terminate_all(self)</code> <a class="header-anchor" href="#func-terminate-all-self" aria-label="Permalink to &quot;***func*** \`terminate_all(self)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/core/manager.py#L186" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> terminate_all</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.targets:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.terminate(name)</span></span></code></pre></div></details><h4 id="func-is-process-alive-self-name-str-bool" tabindex="-1"><em><strong>func</strong></em> <code>is_process_alive(self, name: str) -&gt; bool</code> <a class="header-anchor" href="#func-is-process-alive-self-name-str-bool" aria-label="Permalink to &quot;***func*** \`is_process_alive(self, name: str) -&gt; bool\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>name:</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/core/manager.py#L190" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> is_process_alive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, name: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 检查进程是否存活</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.targets:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Process </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> not found.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.processes[name].is_alive()</span></span></code></pre></div></details>`,31),l=[t];function h(k,p,r,d,g,E){return a(),i("div",null,l)}const o=s(e,[["render",h]]);export{y as __pageData,o as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.core.manager","description":"","frontmatter":{"title":"liteyuki.core.manager"},"headers":[],"relativePath":"dev/api/core/manager.md","filePath":"zh/dev/api/core/manager.md","lastUpdated":null}'),e={name:"dev/api/core/manager.md"},t=n("",31),l=[t];function h(k,p,r,d,g,E){return a(),i("div",null,l)}const o=s(e,[["render",h]]);export{y as __pageData,o as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o as d,j as e,a as i}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.dev","description":"","frontmatter":{"title":"liteyuki.dev","collapsed":true},"headers":[],"relativePath":"dev/api/dev/dev.md","filePath":"zh/dev/api/dev/dev.md","lastUpdated":null}'),s={name:"dev/api/dev/dev.md"},o=e("h1",{id:"liteyuki-dev",tabindex:"-1"},[i("liteyuki.dev "),e("a",{class:"header-anchor",href:"#liteyuki-dev","aria-label":'Permalink to "liteyuki.dev"'},"")],-1),l=e("p",null,"该模块用于存放一些开发工具",-1),r=[o,l];function n(c,v,p,_,u,h){return d(),a("div",null,r)}const k=t(s,[["render",n]]);export{f as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o as d,j as e,a as i}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.dev","description":"","frontmatter":{"title":"liteyuki.dev","collapsed":true},"headers":[],"relativePath":"dev/api/dev/dev.md","filePath":"zh/dev/api/dev/dev.md","lastUpdated":null}'),s={name:"dev/api/dev/dev.md"},o=e("h1",{id:"liteyuki-dev",tabindex:"-1"},[i("liteyuki.dev "),e("a",{class:"header-anchor",href:"#liteyuki-dev","aria-label":'Permalink to "liteyuki.dev"'},"")],-1),l=e("p",null,"该模块用于存放一些开发工具",-1),r=[o,l];function n(c,v,p,_,u,h){return d(),a("div",null,r)}const k=t(s,[["render",n]]);export{f as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o as d,j as e,a as i}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.dev","description":"","frontmatter":{"title":"liteyuki.dev","collapsed":true},"headers":[],"relativePath":"dev/api/dev/index.md","filePath":"zh/dev/api/dev/index.md","lastUpdated":null}'),s={name:"dev/api/dev/index.md"},n=e("h1",{id:"liteyuki-dev",tabindex:"-1"},[i("liteyuki.dev "),e("a",{class:"header-anchor",href:"#liteyuki-dev","aria-label":'Permalink to "liteyuki.dev"'},"")],-1),o=e("p",null,"该模块用于存放一些开发工具",-1),l=[n,o];function r(c,p,_,u,v,h){return d(),a("div",null,l)}const k=t(s,[["render",r]]);export{f as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as t,c as a,o as d,j as e,a as i}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.dev","description":"","frontmatter":{"title":"liteyuki.dev","collapsed":true},"headers":[],"relativePath":"dev/api/dev/index.md","filePath":"zh/dev/api/dev/index.md","lastUpdated":null}'),s={name:"dev/api/dev/index.md"},n=e("h1",{id:"liteyuki-dev",tabindex:"-1"},[i("liteyuki.dev "),e("a",{class:"header-anchor",href:"#liteyuki-dev","aria-label":'Permalink to "liteyuki.dev"'},"")],-1),o=e("p",null,"该模块用于存放一些开发工具",-1),l=[n,o];function r(c,p,_,u,v,h){return d(),a("div",null,l)}const k=t(s,[["render",r]]);export{f as __pageData,k as default};

View File

@ -0,0 +1,44 @@
import{_ as s,c as i,o as a,a9 as e}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.dev.observer","description":"","frontmatter":{"title":"liteyuki.dev.observer"},"headers":[],"relativePath":"dev/api/dev/observer.md","filePath":"zh/dev/api/dev/observer.md","lastUpdated":null}'),n={name:"dev/api/dev/observer.md"},t=e(`<h1 id="liteyuki-dev-observer" tabindex="-1">liteyuki.dev.observer <a class="header-anchor" href="#liteyuki-dev-observer" aria-label="Permalink to &quot;liteyuki.dev.observer&quot;"></a></h1><p>此模块用于注册观察者函数使用watchdog监控文件变化并重启bot 启用该模块需要在配置文件中设置<code>dev_mode</code>为True</p><h3 id="var-callback-func" tabindex="-1">var <code>CALLBACK_FUNC</code> <a class="header-anchor" href="#var-callback-func" aria-label="Permalink to &quot;var \`CALLBACK_FUNC\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 位置1为FileSystemEvent</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>Callable[[FileSystemEvent], None]</code></p></li></ul><h3 id="var-filter-func" tabindex="-1">var <code>FILTER_FUNC</code> <a class="header-anchor" href="#var-filter-func" aria-label="Permalink to &quot;var \`FILTER_FUNC\`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 位置1为FileSystemEvent</p></li><li><p><strong>类型</strong>: <code>TypeAlias</code></p></li><li><p><strong>默认值</strong>: <code>Callable[[FileSystemEvent], bool]</code></p></li></ul><h3 id="func-debounce-wait" tabindex="-1"><em><strong>func</strong></em> <code>debounce(wait)</code> <a class="header-anchor" href="#func-debounce-wait" aria-label="Permalink to &quot;***func*** \`debounce(wait)\`&quot;"></a></h3><p><strong>说明</strong>: 防抖函数</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/dev/observer.py#L20" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> debounce</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(wait):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 防抖函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> decorator</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(func):</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> wrapper</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> nonlocal</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> last_call_time</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> current_time </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> time.time()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> current_time </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> last_call_time </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> wait:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> last_call_time </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> current_time</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">args, </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">kwargs)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> last_call_time </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> wrapper</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> decorator</span></span></code></pre></div></details><h3 id="class-codemodifiedhandler-filesystemeventhandler" tabindex="-1"><em><strong>class</strong></em> <code>CodeModifiedHandler(FileSystemEventHandler)</code> <a class="header-anchor" href="#class-codemodifiedhandler-filesystemeventhandler" aria-label="Permalink to &quot;***class*** \`CodeModifiedHandler(FileSystemEventHandler)\`&quot;"></a></h3><p><code>@debounce(1)</code></p><h4 id="func-on-modified-self-event" tabindex="-1"><em><strong>func</strong></em> <code>on_modified(self, event)</code> <a class="header-anchor" href="#func-on-modified-self-event" aria-label="Permalink to &quot;***func*** \`on_modified(self, event)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/dev/observer.py#L49" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@debounce</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_modified</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, event):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> raise</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> NotImplementedError</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;on_modified must be implemented&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><h4 id="func-on-created-self-event" tabindex="-1"><em><strong>func</strong></em> <code>on_created(self, event)</code> <a class="header-anchor" href="#func-on-created-self-event" aria-label="Permalink to &quot;***func*** \`on_created(self, event)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/dev/observer.py#L52" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_created</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, event):</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.on_modified(event)</span></span></code></pre></div></details><h4 id="func-on-deleted-self-event" tabindex="-1"><em><strong>func</strong></em> <code>on_deleted(self, event)</code> <a class="header-anchor" href="#func-on-deleted-self-event" aria-label="Permalink to &quot;***func*** \`on_deleted(self, event)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/dev/observer.py#L55" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_deleted</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, event):</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.on_modified(event)</span></span></code></pre></div></details><h4 id="func-on-moved-self-event" tabindex="-1"><em><strong>func</strong></em> <code>on_moved(self, event)</code> <a class="header-anchor" href="#func-on-moved-self-event" aria-label="Permalink to &quot;***func*** \`on_moved(self, event)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/dev/observer.py#L58" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_moved</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, event):</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.on_modified(event)</span></span></code></pre></div></details><h4 id="func-on-any-event-self-event" tabindex="-1"><em><strong>func</strong></em> <code>on_any_event(self, event)</code> <a class="header-anchor" href="#func-on-any-event-self-event" aria-label="Permalink to &quot;***func*** \`on_any_event(self, event)\`&quot;"></a></h4><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/dev/observer.py#L61" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_any_event</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, event):</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.on_modified(event)</span></span></code></pre></div></details><h3 id="func-on-file-system-event-directories-tuple-str-recursive-bool-true-event-filter-filter-func-none-callable-callback-func-callback-func" tabindex="-1"><em><strong>func</strong></em> <code>on_file_system_event(directories: tuple[str], recursive: bool = True, event_filter: FILTER_FUNC = None) -&gt; Callable[[CALLBACK_FUNC], CALLBACK_FUNC]</code> <a class="header-anchor" href="#func-on-file-system-event-directories-tuple-str-recursive-bool-true-event-filter-filter-func-none-callable-callback-func-callback-func" aria-label="Permalink to &quot;***func*** \`on_file_system_event(directories: tuple[str], recursive: bool = True, event_filter: FILTER_FUNC = None) -&gt; Callable[[CALLBACK_FUNC], CALLBACK_FUNC]\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>directories: </li><li>recursive: </li><li>event_filter: , True</li></ul></blockquote><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/dev/observer.py#L65" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_file_system_event</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(directories: tuple[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], recursive: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, event_filter: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">FILTER_FUNC</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Callable[[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">CALLBACK_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">CALLBACK_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 注册文件系统变化监听器</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> directories: 监听目录们</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> recursive: 是否递归监听子目录</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> event_filter: 事件过滤器, 返回True则执行回调函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 装饰器装饰一个函数在接收到数据后执行</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> decorator</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(func: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">CALLBACK_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">CALLBACK_FUNC</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> wrapper</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(event: FileSystemEvent):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event_filter </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event_filter(event)):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func(event)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> code_modified_handler </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> CodeModifiedHandler()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> code_modified_handler.on_modified </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> wrapper</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> directory </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> directories:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> observer.schedule(code_modified_handler, directory, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">recursive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">recursive)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> func</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> decorator</span></span></code></pre></div></details>`,27),l=[t];function h(p,k,r,d,o,c){return a(),i("div",null,l)}const y=s(n,[["render",h]]);export{g as __pageData,y as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as e}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.dev.observer","description":"","frontmatter":{"title":"liteyuki.dev.observer"},"headers":[],"relativePath":"dev/api/dev/observer.md","filePath":"zh/dev/api/dev/observer.md","lastUpdated":null}'),n={name:"dev/api/dev/observer.md"},t=e("",27),l=[t];function h(p,k,r,d,o,c){return a(),i("div",null,l)}const y=s(n,[["render",h]]);export{g as __pageData,y as default};

View File

@ -0,0 +1,12 @@
import{_ as i,c as s,o as a,a9 as t}from"./chunks/framework.C4_mTacX.js";const E=JSON.parse('{"title":"liteyuki.dev.plugin","description":"","frontmatter":{"title":"liteyuki.dev.plugin"},"headers":[],"relativePath":"dev/api/dev/plugin.md","filePath":"zh/dev/api/dev/plugin.md","lastUpdated":null}'),n={name:"dev/api/dev/plugin.md"},l=t(`<h1 id="liteyuki-dev-plugin" tabindex="-1">liteyuki.dev.plugin <a class="header-anchor" href="#liteyuki-dev-plugin" aria-label="Permalink to &quot;liteyuki.dev.plugin&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/8/18 上午5:04 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : plugin.py @Software: PyCharm</p><h3 id="func-run-plugins-module-path-str-path" tabindex="-1"><em><strong>func</strong></em> <code>run_plugins(*module_path: str | Path)</code> <a class="header-anchor" href="#func-run-plugins-module-path-str-path" aria-label="Permalink to &quot;***func*** \`run_plugins(*module_path: str | Path)\`&quot;"></a></h3><p><strong>说明</strong>: 运行插件无需手动初始化bot</p><p><strong>参数</strong>:</p><blockquote><ul><li>module_path: 插件路径,参考<code>liteyuki.load_plugin</code>的函数签名</li></ul></blockquote><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/dev/plugin.py#L17" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> run_plugins</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module_path: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Path):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 运行插件无需手动初始化bot</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> module_path: 插件路径参考\`liteyuki.load_plugin\`的函数签名</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cfg </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_config_in_default()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugins </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cfg.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;liteyuki.plugins&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, [])</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugins.extend(module_path)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> cfg[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;liteyuki.plugins&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugins</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> bot </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> LiteyukiBot(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">cfg)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> bot.run()</span></span></code></pre></div></details>`,8),e=[l];function p(h,k,r,d,o,u){return a(),s("div",null,e)}const c=i(n,[["render",p]]);export{E as __pageData,c as default};

View File

@ -0,0 +1 @@
import{_ as i,c as s,o as a,a9 as t}from"./chunks/framework.C4_mTacX.js";const E=JSON.parse('{"title":"liteyuki.dev.plugin","description":"","frontmatter":{"title":"liteyuki.dev.plugin"},"headers":[],"relativePath":"dev/api/dev/plugin.md","filePath":"zh/dev/api/dev/plugin.md","lastUpdated":null}'),n={name:"dev/api/dev/plugin.md"},l=t("",8),e=[l];function p(h,k,r,d,o,u){return a(),s("div",null,e)}const c=i(n,[["render",p]]);export{E as __pageData,c as default};

View File

@ -0,0 +1 @@
import{_ as i,c as a,o,j as e,a as t}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.exception","description":"","frontmatter":{"title":"liteyuki.exception"},"headers":[],"relativePath":"dev/api/exception.md","filePath":"zh/dev/api/exception.md","lastUpdated":null}'),n={name:"dev/api/exception.md"},c=e("h1",{id:"liteyuki-exception",tabindex:"-1"},[t("liteyuki.exception "),e("a",{class:"header-anchor",href:"#liteyuki-exception","aria-label":'Permalink to "liteyuki.exception"'},"")],-1),s=e("p",null,"exception模块包含了liteyuki运行中的所有错误",-1),l=e("h3",{id:"class-liteyukiexception-baseexception",tabindex:"-1"},[e("em",null,[e("strong",null,"class")]),t(),e("code",null,"LiteyukiException(BaseException)"),t(),e("a",{class:"header-anchor",href:"#class-liteyukiexception-baseexception","aria-label":'Permalink to "***class*** `LiteyukiException(BaseException)`"'},"")],-1),p=[c,s,l];function r(d,x,u,_,h,k){return o(),a("div",null,p)}const f=i(n,[["render",r]]);export{y as __pageData,f as default};

View File

@ -0,0 +1 @@
import{_ as i,c as a,o,j as e,a as t}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.exception","description":"","frontmatter":{"title":"liteyuki.exception"},"headers":[],"relativePath":"dev/api/exception.md","filePath":"zh/dev/api/exception.md","lastUpdated":null}'),n={name:"dev/api/exception.md"},c=e("h1",{id:"liteyuki-exception",tabindex:"-1"},[t("liteyuki.exception "),e("a",{class:"header-anchor",href:"#liteyuki-exception","aria-label":'Permalink to "liteyuki.exception"'},"")],-1),s=e("p",null,"exception模块包含了liteyuki运行中的所有错误",-1),l=e("h3",{id:"class-liteyukiexception-baseexception",tabindex:"-1"},[e("em",null,[e("strong",null,"class")]),t(),e("code",null,"LiteyukiException(BaseException)"),t(),e("a",{class:"header-anchor",href:"#class-liteyukiexception-baseexception","aria-label":'Permalink to "***class*** `LiteyukiException(BaseException)`"'},"")],-1),p=[c,s,l];function r(d,x,u,_,h,k){return o(),a("div",null,p)}const f=i(n,[["render",r]]);export{y as __pageData,f as default};

View File

@ -0,0 +1 @@
import{_ as e,c as t,o as a,a9 as i}from"./chunks/framework.C4_mTacX.js";const v=JSON.parse('{"title":"liteyuki API","description":"","frontmatter":{"title":"liteyuki API","collapsed":true,"order":100},"headers":[],"relativePath":"dev/api/index.md","filePath":"zh/dev/api/index.md","lastUpdated":null}'),o={name:"dev/api/index.md"},r=i('<h1 id="liteyuki" tabindex="-1">liteyuki <a class="header-anchor" href="#liteyuki" aria-label="Permalink to &quot;liteyuki&quot;"></a></h1><p>此模块为liteyuki的框架整体</p><p>This module is the overall framework of liteyuki.</p><h3 id="var-version" tabindex="-1">var <code>__version__</code> <a class="header-anchor" href="#var-version" aria-label="Permalink to &quot;var `__version__`&quot;"></a></h3><ul><li><p><strong>说明</strong>: 测试版本号</p></li><li><p><strong>默认值</strong>: <code>&#39;6.3.10&#39;</code></p></li></ul>',5),l=[r];function n(s,d,_,c,p,u){return a(),t("div",null,l)}const k=e(o,[["render",n]]);export{v as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as e,c as t,o as a,a9 as i}from"./chunks/framework.C4_mTacX.js";const v=JSON.parse('{"title":"liteyuki API","description":"","frontmatter":{"title":"liteyuki API","collapsed":true,"order":100},"headers":[],"relativePath":"dev/api/index.md","filePath":"zh/dev/api/index.md","lastUpdated":null}'),o={name:"dev/api/index.md"},r=i("",5),l=[r];function n(s,d,_,c,p,u){return a(),t("div",null,l)}const k=e(o,[["render",n]]);export{v as __pageData,k as default};

View File

@ -0,0 +1,18 @@
import{_ as s,c as i,o as a,a9 as h}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.log","description":"","frontmatter":{"title":"liteyuki.log"},"headers":[],"relativePath":"dev/api/log.md","filePath":"zh/dev/api/log.md","lastUpdated":null}'),t={name:"dev/api/log.md"},k=h(`<h1 id="liteyuki-log" tabindex="-1">liteyuki.log <a class="header-anchor" href="#liteyuki-log" aria-label="Permalink to &quot;liteyuki.log&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/7/27 上午9:12 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : log.py @Software: PyCharm</p><h3 id="func-get-format-level-str-str" tabindex="-1"><em><strong>func</strong></em> <code>get_format(level: str) -&gt; str</code> <a class="header-anchor" href="#func-get-format-level-str-str" aria-label="Permalink to &quot;***func*** \`get_format(level: str) -&gt; str\`&quot;"></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/log.py#L34" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_format</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(level: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> level </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;DEBUG&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> debug_format</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> default_format</span></span></code></pre></div></details><h3 id="func-init-log-config-dict" tabindex="-1"><em><strong>func</strong></em> <code>init_log(config: dict)</code> <a class="header-anchor" href="#func-init-log-config-dict" aria-label="Permalink to &quot;***func*** \`init_log(config: dict)\`&quot;"></a></h3><p><strong></strong>: </p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/log.py#L41" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> init_log</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(config: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">dict</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 在语言加载完成后执行</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.remove()</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.add(sys.stdout, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">level</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">diagnose</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">False</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">format</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">get_format(config.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;log_level&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;INFO&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)))</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> show_icon </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;log_icon&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.level(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;DEBUG&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">color</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;blue&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">icon</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;🐛&#39;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> show_icon </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">DEBUG&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.level(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;INFO&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">color</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;normal&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">icon</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&#39;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> show_icon </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.level(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;SUCCESS&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">color</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;green&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">icon</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&#39;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> show_icon </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">SUCCESS&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.level(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;WARNING&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">color</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;yellow&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">icon</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&#39;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> show_icon </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">WARNING&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.level(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;ERROR&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">color</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;red&gt;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">icon</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&#39;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> show_icon </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ERROR&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details>`,8),l=[k];function n(p,e,E,r,g,d){return a(),i("div",null,l)}const o=s(t,[["render",n]]);export{y as __pageData,o as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as h}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.log","description":"","frontmatter":{"title":"liteyuki.log"},"headers":[],"relativePath":"dev/api/log.md","filePath":"zh/dev/api/log.md","lastUpdated":null}'),t={name:"dev/api/log.md"},k=h("",8),l=[k];function n(p,e,E,r,g,d){return a(),i("div",null,l)}const o=s(t,[["render",n]]);export{y as __pageData,o as default};

View File

@ -0,0 +1,36 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const F=JSON.parse('{"title":"liteyuki.message.event","description":"","frontmatter":{"title":"liteyuki.message.event"},"headers":[],"relativePath":"dev/api/message/event.md","filePath":"zh/dev/api/message/event.md","lastUpdated":null}'),e={name:"dev/api/message/event.md"},t=n(`<h1 id="liteyuki-message-event" tabindex="-1">liteyuki.message.event <a class="header-anchor" href="#liteyuki-message-event" aria-label="Permalink to &quot;liteyuki.message.event&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/8/19 下午10:47 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : event.py @Software: PyCharm</p><h3 id="class-messageevent" tabindex="-1"><em><strong>class</strong></em> <code>MessageEvent</code> <a class="header-anchor" href="#class-messageevent" aria-label="Permalink to &quot;***class*** \`MessageEvent\`&quot;"></a></h3><h4 id="func-init-self-bot-id-str-message-list-dict-str-any-str-message-type-str-raw-message-str-session-id-str-user-id-str-session-type-str-receive-channel-optional-channel-messageevent-none-data-optional-dict-str-any-none" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, bot_id: str, message: list[dict[str, Any]] | str, message_type: str, raw_message: str, session_id: str, user_id: str, session_type: str, receive_channel: Optional[Channel[MessageEvent]] = None, data: Optional[dict[str, Any]] = None)</code> <a class="header-anchor" href="#func-init-self-bot-id-str-message-list-dict-str-any-str-message-type-str-raw-message-str-session-id-str-user-id-str-session-type-str-receive-channel-optional-channel-messageevent-none-data-optional-dict-str-any-none" aria-label="Permalink to &quot;***func*** \`__init__(self, bot_id: str, message: list[dict[str, Any]] | str, message_type: str, raw_message: str, session_id: str, user_id: str, session_type: str, receive_channel: Optional[Channel[MessageEvent]] = None, data: Optional[dict[str, Any]] = None)\`&quot;"></a></h4><p><strong>说明</strong>: 轻雪抽象消息事件</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/event.py#L18" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, bot_id: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, message: list[dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">|</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, message_type: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, raw_message: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, session_id: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, user_id: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, session_type: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, receive_channel: Optional[Channel[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;MessageEvent&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, data: Optional[dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 轻雪抽象消息事件</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> bot_id: 机器人ID</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> message: 消息消息段数组[{type: str, data: dict[str, Any]}]</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> raw_message: 原始消息(通常为纯文本的格式)</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> message_type: 消息类型(private, group, other)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> session_id: 会话ID(私聊通常为用户ID群聊通常为群ID)</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> session_type: 会话类型(private, group)</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> receive_channel: 接收频道(用于回复消息)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> data: 附加数据</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">is</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> {}</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.message_type </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> message_type</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.data </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> data</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.bot_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> bot_id</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.message </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> message</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.raw_message </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> raw_message</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.session_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> session_id</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.session_type </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> session_type</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.user_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> user_id</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.receive_channel </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> receive_channel</span></span></code></pre></div></details><h4 id="func-reply-self-message-str-dict-str-any" tabindex="-1"><em><strong>func</strong></em> <code>reply(self, message: str | dict[str, Any])</code> <a class="header-anchor" href="#func-reply-self-message-str-dict-str-any" aria-label="Permalink to &quot;***func*** \`reply(self, message: str | dict[str, Any])\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>message:</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/event.py#L66" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> reply</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, message: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Any]):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 回复消息</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> message:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> reply_event </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> MessageEvent(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">message_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.session_type, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">message, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">raw_message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">data</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;message&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: message}, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">bot_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.bot_id, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">session_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.session_id, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">user_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.user_id, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">session_type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.session_type, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">receive_channel</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.receive_channel:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.receive_channel.send(reply_event)</span></span></code></pre></div></details>`,12),h=[t];function l(k,p,r,d,E,g){return a(),i("div",null,h)}const o=s(e,[["render",l]]);export{F as __pageData,o as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const F=JSON.parse('{"title":"liteyuki.message.event","description":"","frontmatter":{"title":"liteyuki.message.event"},"headers":[],"relativePath":"dev/api/message/event.md","filePath":"zh/dev/api/message/event.md","lastUpdated":null}'),e={name:"dev/api/message/event.md"},t=n("",12),h=[t];function l(k,p,r,d,E,g){return a(),i("div",null,h)}const o=s(e,[["render",l]]);export{F as __pageData,o as default};

View File

@ -0,0 +1 @@
import{_ as a,c as s,o as i,j as e,a as t}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message","description":"","frontmatter":{"title":"liteyuki.message","collapsed":true},"headers":[],"relativePath":"dev/api/message/index.md","filePath":"zh/dev/api/message/index.md","lastUpdated":null}'),o={name:"dev/api/message/index.md"},l=e("h1",{id:"liteyuki-message",tabindex:"-1"},[t("liteyuki.message "),e("a",{class:"header-anchor",href:"#liteyuki-message","aria-label":'Permalink to "liteyuki.message"'},"")],-1),r=e("p",null,"Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved",-1),n=e("p",null,[t("@Time : 2024/8/19 下午10:44 @Author : snowykami @Email : "),e("a",{href:"mailto:snowykami@outlook.com",target:"_blank",rel:"noreferrer"},"snowykami@outlook.com"),t(" @File : "),e("strong",null,"init"),t(".py.py @Software: PyCharm")],-1),d=[l,r,n];function m(c,p,u,_,h,k){return i(),s("div",null,d)}const f=a(o,[["render",m]]);export{y as __pageData,f as default};

View File

@ -0,0 +1 @@
import{_ as a,c as s,o as i,j as e,a as t}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message","description":"","frontmatter":{"title":"liteyuki.message","collapsed":true},"headers":[],"relativePath":"dev/api/message/index.md","filePath":"zh/dev/api/message/index.md","lastUpdated":null}'),o={name:"dev/api/message/index.md"},l=e("h1",{id:"liteyuki-message",tabindex:"-1"},[t("liteyuki.message "),e("a",{class:"header-anchor",href:"#liteyuki-message","aria-label":'Permalink to "liteyuki.message"'},"")],-1),r=e("p",null,"Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved",-1),n=e("p",null,[t("@Time : 2024/8/19 下午10:44 @Author : snowykami @Email : "),e("a",{href:"mailto:snowykami@outlook.com",target:"_blank",rel:"noreferrer"},"snowykami@outlook.com"),t(" @File : "),e("strong",null,"init"),t(".py.py @Software: PyCharm")],-1),d=[l,r,n];function m(c,p,u,_,h,k){return i(),s("div",null,d)}const f=a(o,[["render",m]]);export{y as __pageData,f as default};

View File

@ -0,0 +1,35 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message.matcher","description":"","frontmatter":{"title":"liteyuki.message.matcher"},"headers":[],"relativePath":"dev/api/message/matcher.md","filePath":"zh/dev/api/message/matcher.md","lastUpdated":null}'),e={name:"dev/api/message/matcher.md"},t=n(`<h1 id="liteyuki-message-matcher" tabindex="-1">liteyuki.message.matcher <a class="header-anchor" href="#liteyuki-message-matcher" aria-label="Permalink to &quot;liteyuki.message.matcher&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/8/19 下午10:51 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : matcher.py @Software: PyCharm</p><h3 id="class-matcher" tabindex="-1"><em><strong>class</strong></em> <code>Matcher</code> <a class="header-anchor" href="#class-matcher" aria-label="Permalink to &quot;***class*** \`Matcher\`&quot;"></a></h3><h4 id="func-init-self-rule-rule-priority-int-block-bool" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, rule: Rule, priority: int, block: bool)</code> <a class="header-anchor" href="#func-init-self-rule-rule-priority-int-block-bool" aria-label="Permalink to &quot;***func*** \`__init__(self, rule: Rule, priority: int, block: bool)\`&quot;"></a></h4><p><strong>说明</strong>: 匹配器</p><p><strong>参数</strong>:</p><blockquote><ul><li>rule: 规则</li><li>priority: 优先级 &gt;= 0</li><li>block: 是否阻断后续优先级更低的匹配器</li></ul></blockquote><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/matcher.py#L21" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> __init__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, rule: Rule, priority: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">int</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, block: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 匹配器</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> rule: 规则</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> priority: 优先级 &gt;= 0</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> block: 是否阻断后续优先级更低的匹配器</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.rule </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> rule</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.priority </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> priority</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.block </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> block</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.handlers: list[EventHandler] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span></code></pre></div></details><h4 id="func-handle-self-callable-eventhandler-eventhandler" tabindex="-1"><em><strong>func</strong></em> <code>handle(self) -&gt; Callable[[EventHandler], EventHandler]</code> <a class="header-anchor" href="#func-handle-self-callable-eventhandler-eventhandler" aria-label="Permalink to &quot;***func*** \`handle(self) -&gt; Callable[[EventHandler], EventHandler]\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>: handler</p><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/matcher.py#L37" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self) -&gt; Callable[[EventHandler], EventHandler]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 添加处理函数装饰器</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 装饰器 handler</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> decorator</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(handler: EventHandler) -&gt; EventHandler:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.handlers.append(handler)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> handler</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> decorator</span></span></code></pre></div></details><h4 id="async-func-run-self-event-messageevent-none" tabindex="-1"><em><strong>async func</strong></em> <code>run(self, event: MessageEvent) -&gt; None</code> <a class="header-anchor" href="#async-func-run-self-event-messageevent-none" aria-label="Permalink to &quot;***async func*** \`run(self, event: MessageEvent) -&gt; None\`&quot;"></a></h4><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>event:</li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/matcher.py#L49" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> run</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(self, event: MessageEvent) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 运行处理函数</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> event:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.rule(event):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> handler </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> self</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.handlers:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> handler(event)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Exception</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> traceback.print_exc()</span></span></code></pre></div></details>`,18),l=[t];function h(p,k,r,d,o,c){return a(),i("div",null,l)}const E=s(e,[["render",h]]);export{y as __pageData,E as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message.matcher","description":"","frontmatter":{"title":"liteyuki.message.matcher"},"headers":[],"relativePath":"dev/api/message/matcher.md","filePath":"zh/dev/api/message/matcher.md","lastUpdated":null}'),e={name:"dev/api/message/matcher.md"},t=n("",18),l=[t];function h(p,k,r,d,o,c){return a(),i("div",null,l)}const E=s(e,[["render",h]]);export{y as __pageData,E as default};

View File

@ -0,0 +1 @@
import{_ as s,c as t,o as i,j as e,a}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message","description":"","frontmatter":{"title":"liteyuki.message","collapsed":true},"headers":[],"relativePath":"dev/api/message/message.md","filePath":"zh/dev/api/message/message.md","lastUpdated":null}'),o={name:"dev/api/message/message.md"},l=e("h1",{id:"liteyuki-message",tabindex:"-1"},[a("liteyuki.message "),e("a",{class:"header-anchor",href:"#liteyuki-message","aria-label":'Permalink to "liteyuki.message"'},"")],-1),r=e("p",null,"Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved",-1),n=e("p",null,[a("@Time : 2024/8/19 下午10:44 @Author : snowykami @Email : "),e("a",{href:"mailto:snowykami@outlook.com",target:"_blank",rel:"noreferrer"},"snowykami@outlook.com"),a(" @File : "),e("strong",null,"init"),a(".py.py @Software: PyCharm")],-1),m=[l,r,n];function d(c,p,u,_,g,h){return i(),t("div",null,m)}const f=s(o,[["render",d]]);export{y as __pageData,f as default};

View File

@ -0,0 +1 @@
import{_ as s,c as t,o as i,j as e,a}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message","description":"","frontmatter":{"title":"liteyuki.message","collapsed":true},"headers":[],"relativePath":"dev/api/message/message.md","filePath":"zh/dev/api/message/message.md","lastUpdated":null}'),o={name:"dev/api/message/message.md"},l=e("h1",{id:"liteyuki-message",tabindex:"-1"},[a("liteyuki.message "),e("a",{class:"header-anchor",href:"#liteyuki-message","aria-label":'Permalink to "liteyuki.message"'},"")],-1),r=e("p",null,"Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved",-1),n=e("p",null,[a("@Time : 2024/8/19 下午10:44 @Author : snowykami @Email : "),e("a",{href:"mailto:snowykami@outlook.com",target:"_blank",rel:"noreferrer"},"snowykami@outlook.com"),a(" @File : "),e("strong",null,"init"),a(".py.py @Software: PyCharm")],-1),m=[l,r,n];function d(c,p,u,_,g,h){return i(),t("div",null,m)}const f=s(o,[["render",d]]);export{y as __pageData,f as default};

View File

@ -0,0 +1,15 @@
import{_ as s,c as i,o as a,a9 as e}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.message.on","description":"","frontmatter":{"title":"liteyuki.message.on"},"headers":[],"relativePath":"dev/api/message/on.md","filePath":"zh/dev/api/message/on.md","lastUpdated":null}'),t={name:"dev/api/message/on.md"},n=e(`<h1 id="liteyuki-message-on" tabindex="-1">liteyuki.message.on <a class="header-anchor" href="#liteyuki-message-on" aria-label="Permalink to &quot;liteyuki.message.on&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/8/19 下午10:52 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : on.py @Software: PyCharm</p><h3 id="func-add-matcher-matcher-matcher" tabindex="-1"><em><strong>func</strong></em> <code>add_matcher(matcher: Matcher)</code> <a class="header-anchor" href="#func-add-matcher-matcher-matcher" aria-label="Permalink to &quot;***func*** \`add_matcher(matcher: Matcher)\`&quot;"></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/on.py#L41" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> add_matcher</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(matcher: Matcher):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> i, m </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> enumerate</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(_matcher_list):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> m.priority </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&lt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> matcher.priority:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _matcher_list.insert(i, matcher)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> break</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _matcher_list.append(matcher)</span></span></code></pre></div></details><h3 id="func-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher" tabindex="-1"><em><strong>func</strong></em> <code>on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -&gt; Matcher</code> <a class="header-anchor" href="#func-on-message-rule-rule-empty-rule-priority-int-0-block-bool-false-matcher" aria-label="Permalink to &quot;***func*** \`on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -&gt; Matcher\`&quot;"></a></h3><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/on.py#L50" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_message</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(rule: Rule</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">empty_rule, priority: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">int</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, block: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">False</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Matcher:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> matcher </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Matcher(rule, priority, block)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> add_matcher(matcher)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> matcher</span></span></code></pre></div></details><h3 id="func-on-keywords-keywords-list-str-rule-empty-rule-priority-int-0-block-bool-false-matcher" tabindex="-1"><em><strong>func</strong></em> <code>on_keywords(keywords: list[str], rule = empty_rule, priority: int = 0, block: bool = False) -&gt; Matcher</code> <a class="header-anchor" href="#func-on-keywords-keywords-list-str-rule-empty-rule-priority-int-0-block-bool-false-matcher" aria-label="Permalink to &quot;***func*** \`on_keywords(keywords: list[str], rule = empty_rule, priority: int = 0, block: bool = False) -&gt; Matcher\`&quot;"></a></h3><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/message/on.py#L57" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_keywords</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(keywords: list[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], rule</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">empty_rule, priority: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">int</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, block: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">False</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; Matcher:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> @Rule</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> on_keywords_rule</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(event: MessageEvent):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> any</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">((keyword </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event.raw_message </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> keyword </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> keywords))</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> on_message(on_keywords_rule </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&amp;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> rule, priority, block)</span></span></code></pre></div></details>`,9),l=[n];function h(k,r,p,o,d,y){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{g as __pageData,E as default};

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as e}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.message.on","description":"","frontmatter":{"title":"liteyuki.message.on"},"headers":[],"relativePath":"dev/api/message/on.md","filePath":"zh/dev/api/message/on.md","lastUpdated":null}'),t={name:"dev/api/message/on.md"},n=e("",9),l=[n];function h(k,r,p,o,d,y){return a(),i("div",null,l)}const E=s(t,[["render",h]]);export{g as __pageData,E as default};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as e}from"./chunks/framework.C4_mTacX.js";const c=JSON.parse('{"title":"liteyuki.message.rule","description":"","frontmatter":{"title":"liteyuki.message.rule"},"headers":[],"relativePath":"dev/api/message/rule.md","filePath":"zh/dev/api/message/rule.md","lastUpdated":null}'),t={name:"dev/api/message/rule.md"},n=e("",20),l=[n];function h(r,p,k,d,o,u){return a(),i("div",null,l)}const y=s(t,[["render",h]]);export{c as __pageData,y as default};

View File

@ -0,0 +1 @@
import{_ as a,c as t,o as i,j as e,a as s}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message.session","description":"","frontmatter":{"title":"liteyuki.message.session"},"headers":[],"relativePath":"dev/api/message/session.md","filePath":"zh/dev/api/message/session.md","lastUpdated":null}'),o={name:"dev/api/message/session.md"},n=e("h1",{id:"liteyuki-message-session",tabindex:"-1"},[s("liteyuki.message.session "),e("a",{class:"header-anchor",href:"#liteyuki-message-session","aria-label":'Permalink to "liteyuki.message.session"'},"")],-1),r=e("p",null,"Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved",-1),l=e("p",null,[s("@Time : 2024/8/19 下午10:47 @Author : snowykami @Email : "),e("a",{href:"mailto:snowykami@outlook.com",target:"_blank",rel:"noreferrer"},"snowykami@outlook.com"),s(" @File : session.py @Software: PyCharm")],-1),m=[n,r,l];function d(c,_,p,u,h,k){return i(),t("div",null,m)}const f=a(o,[["render",d]]);export{y as __pageData,f as default};

View File

@ -0,0 +1 @@
import{_ as a,c as t,o as i,j as e,a as s}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.message.session","description":"","frontmatter":{"title":"liteyuki.message.session"},"headers":[],"relativePath":"dev/api/message/session.md","filePath":"zh/dev/api/message/session.md","lastUpdated":null}'),o={name:"dev/api/message/session.md"},n=e("h1",{id:"liteyuki-message-session",tabindex:"-1"},[s("liteyuki.message.session "),e("a",{class:"header-anchor",href:"#liteyuki-message-session","aria-label":'Permalink to "liteyuki.message.session"'},"")],-1),r=e("p",null,"Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved",-1),l=e("p",null,[s("@Time : 2024/8/19 下午10:47 @Author : snowykami @Email : "),e("a",{href:"mailto:snowykami@outlook.com",target:"_blank",rel:"noreferrer"},"snowykami@outlook.com"),s(" @File : session.py @Software: PyCharm")],-1),m=[n,r,l];function d(c,_,p,u,h,k){return i(),t("div",null,m)}const f=a(o,[["render",d]]);export{y as __pageData,f as default};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
import{_ as s,c as i,o as a,a9 as t}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.mkdoc","description":"","frontmatter":{"title":"liteyuki.mkdoc"},"headers":[],"relativePath":"dev/api/mkdoc.md","filePath":"zh/dev/api/mkdoc.md","lastUpdated":null}'),n={name:"dev/api/mkdoc.md"},h=t("",65),k=[h];function l(p,e,r,E,d,g){return a(),i("div",null,k)}const o=s(n,[["render",l]]);export{y as __pageData,o as default};

View File

@ -0,0 +1,7 @@
import{_ as i,c as s,o as t,a9 as a}from"./chunks/framework.C4_mTacX.js";const k=JSON.parse('{"title":"liteyuki.plugin","description":"","frontmatter":{"title":"liteyuki.plugin","collapsed":true},"headers":[],"relativePath":"dev/api/plugin/index.md","filePath":"zh/dev/api/plugin/index.md","lastUpdated":null}'),n={name:"dev/api/plugin/index.md"},e=a(`<h1 id="liteyuki-plugin" tabindex="-1">liteyuki.plugin <a class="header-anchor" href="#liteyuki-plugin" aria-label="Permalink to &quot;liteyuki.plugin&quot;"></a></h1><h3 id="func-get-loaded-plugins-dict-str-plugin" tabindex="-1"><em><strong>func</strong></em> <code>get_loaded_plugins() -&gt; dict[str, Plugin]</code> <a class="header-anchor" href="#func-get-loaded-plugins-dict-str-plugin" aria-label="Permalink to &quot;***func*** \`get_loaded_plugins() -&gt; dict[str, Plugin]\`&quot;"></a></h3><p><strong>说明</strong>: 获取已加载的插件</p><p><strong>返回</strong>: dict[str, Plugin]: 插件字典</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/plugin/__init__.py#L13" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_loaded_plugins</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Plugin]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取已加载的插件</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dict[str, Plugin]: 插件字典</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _plugins</span></span></code></pre></div></details>`,5),l=[e];function p(d,r,h,u,o,g){return t(),s("div",null,l)}const _=i(n,[["render",p]]);export{k as __pageData,_ as default};

View File

@ -0,0 +1 @@
import{_ as i,c as s,o as t,a9 as a}from"./chunks/framework.C4_mTacX.js";const k=JSON.parse('{"title":"liteyuki.plugin","description":"","frontmatter":{"title":"liteyuki.plugin","collapsed":true},"headers":[],"relativePath":"dev/api/plugin/index.md","filePath":"zh/dev/api/plugin/index.md","lastUpdated":null}'),n={name:"dev/api/plugin/index.md"},e=a("",5),l=[e];function p(d,r,h,u,o,g){return t(),s("div",null,l)}const _=i(n,[["render",p]]);export{k as __pageData,_ as default};

View File

@ -0,0 +1,83 @@
import{_ as h,D as l,c as t,j as i,a as s,I as k,w as p,a9 as a,o as e}from"./chunks/framework.C4_mTacX.js";const B=JSON.parse('{"title":"liteyuki.plugin.load","description":"","frontmatter":{"title":"liteyuki.plugin.load"},"headers":[],"relativePath":"dev/api/plugin/load.md","filePath":"zh/dev/api/plugin/load.md","lastUpdated":null}'),E={name:"dev/api/plugin/load.md"},d=a(`<h1 id="liteyuki-plugin-load" tabindex="-1">liteyuki.plugin.load <a class="header-anchor" href="#liteyuki-plugin-load" aria-label="Permalink to &quot;liteyuki.plugin.load&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/7/23 下午11:59 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : load.py @Software: PyCharm</p><h3 id="func-load-plugin-module-path-str-path-optional-plugin" tabindex="-1"><em><strong>func</strong></em> <code>load_plugin(module_path: str | Path) -&gt; Optional[Plugin]</code> <a class="header-anchor" href="#func-load-plugin-module-path-str-path-optional-plugin" aria-label="Permalink to &quot;***func*** \`load_plugin(module_path: str | Path) -&gt; Optional[Plugin]\`&quot;"></a></h3><p><strong>说明</strong>: 加载单个插件,可以是本地插件或是通过 <code>pip</code> 安装的插件。</p><p><strong>参数</strong>:</p><blockquote><ul><li>module_path: 插件名称 <code>path.to.your.plugin</code></li><li>或插件路径 <code>pathlib.Path(path/to/your/plugin)</code>:</li></ul></blockquote><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/plugin/load.py#L30" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> load_plugin</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(module_path: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> |</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Path) -&gt; Optional[Plugin]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;加载单个插件可以是本地插件或是通过 \`pip\` 安装的插件。</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 参数:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> module_path: 插件名称 \`path.to.your.plugin\`</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 或插件路径 \`pathlib.Path(path/to/your/plugin)\`</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module_path </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> path_to_module_name(Path(module_path)) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> isinstance</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(module_path, Path) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module_path</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> import_module(module_path)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _plugins[module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Plugin(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">module</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">module_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module_path)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__dict__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;__plugin_metadata__&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> metadata: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;PluginMetadata&#39;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__dict__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;__plugin_metadata__&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> display_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.split(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__dict__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;__liteyuki_plugin_meta__&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> metadata: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;PluginMetadata&#39;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__dict__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;__liteyuki_plugin_meta__&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> display_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> format_display_name(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">metadata.name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.split(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">)&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, metadata.type)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__dict__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.get(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;__plugin_meta__&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> metadata: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;PluginMetadata&#39;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__dict__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;__plugin_meta__&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> display_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> format_display_name(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">metadata.name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.split(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">)&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, metadata.type)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.opt(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">colors</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;The metadata of Liteyuki plugin &quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot; is not specified, use empty.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> metadata </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginMetadata(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> display_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">.split(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _plugins[module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">].metadata </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> metadata</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.opt(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">colors</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).success(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Succeeded to load liteyuki plugin &quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">display_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _plugins[module.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">__name__</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Exception</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> e:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.opt(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">colors</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">).success(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;Failed to load liteyuki plugin &quot;&lt;r&gt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">module_path</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&lt;/r&gt;&quot;&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> traceback.print_exc()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span></span></code></pre></div></details><h3 id="func-load-plugins-plugin-dir-str-ignore-warning-bool-true-set-plugin" tabindex="-1"><em><strong>func</strong></em> <code>load_plugins(*plugin_dir: str, *, ignore_warning: bool = True) -&gt; set[Plugin]</code> <a class="header-anchor" href="#func-load-plugins-plugin-dir-str-ignore-warning-bool-true-set-plugin" aria-label="Permalink to &quot;***func*** \`load_plugins(*plugin_dir: str, *, ignore_warning: bool = True) -&gt; set[Plugin]\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>plugin_dir: </li><li>ignore_warning: </li></ul></blockquote><details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/plugin/load.py#L88" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> load_plugins</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">plugin_dir: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, ignore_warning: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bool</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">True</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) -&gt; set[Plugin]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;导入文件夹下多个插件</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 参数:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> plugin_dir: 文件夹路径</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ignore_warning: 是否忽略警告通常是目录不存在或目录为空</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugins </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> set</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> dir_path </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugin_dir:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.path.exists(dir_path):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ignore_warning:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Plugins dir &#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">dir_path</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39; does not exist.&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> continue</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.listdir(dir_path):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ignore_warning:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Plugins dir &#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">dir_path</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39; is empty.&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> continue</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.path.isdir(dir_path):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ignore_warning:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.warning(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Plugins dir &#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">dir_path</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39; is not a directory.&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> continue</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> f </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.listdir(dir_path):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> path </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Path(os.path.join(dir_path, f))</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.path.isfile(path) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> f.endswith(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;.py&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (f </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;__init__.py&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">path_to_module_name(Path(dir_path))</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">f[:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">-</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> elif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.path.isdir(path) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> os.path.exists(os.path.join(path, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;__init__.py&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> path_to_module_name(path)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> module_name:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_plugin(module_name)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _plugins.get(module_name):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugins.add(_plugins[module_name])</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugins</span></span></code></pre></div></details><h3 id="func-format-display-name-display-name-str-plugin-type-plugintype-str" tabindex="-1"><em><strong>func</strong></em> <code>format_display_name(display_name: str, plugin_type: PluginType) -&gt; str</code> <a class="header-anchor" href="#func-format-display-name-display-name-str-plugin-type-plugintype-str" aria-label="Permalink to &quot;***func*** \`format_display_name(display_name: str, plugin_type: PluginType) -&gt; str\`&quot;"></a></h3><p><strong></strong>: </p><p><strong></strong>:</p><blockquote><ul><li>display_name: </li><li>plugin_type: </li></ul></blockquote>`,17),r=i("strong",null,"",-1),g=a(`<details><summary><b></b> <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/plugin/load.py#L132" target="_blank">GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> format_display_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(display_name: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, plugin_type: PluginType) -&gt; </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 设置插件名称颜色根据不同类型插件设置颜色</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Args:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> display_name: 插件名称</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> plugin_type: 插件类型</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> str: 设置后的插件名称 &lt;y&gt;name&lt;/y&gt;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> color </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;y&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> match</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugin_type:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginType.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">APPLICATION</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> color </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;m&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginType.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">TEST</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> color </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;g&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginType.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">MODULE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> color </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;e&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> case</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> PluginType.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">SERVICE</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> color </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &#39;c&#39;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;&lt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">color</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&gt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">display_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> [</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">plugin_type.name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">]&lt;/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">color</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&gt;&#39;</span></span></code></pre></div></details>`,1);function y(F,o,u,_,C,c){const n=l("y");return e(),t("div",null,[d,i("p",null,[r,s(": str: "),k(n,null,{default:p(()=>[s("name")]),_:1})]),g])}const A=h(E,[["render",y]]);export{B as __pageData,A as default};

View File

@ -0,0 +1 @@
import{_ as h,D as l,c as t,j as i,a as s,I as k,w as p,a9 as a,o as e}from"./chunks/framework.C4_mTacX.js";const B=JSON.parse('{"title":"liteyuki.plugin.load","description":"","frontmatter":{"title":"liteyuki.plugin.load"},"headers":[],"relativePath":"dev/api/plugin/load.md","filePath":"zh/dev/api/plugin/load.md","lastUpdated":null}'),E={name:"dev/api/plugin/load.md"},d=a("",17),r=i("strong",null,"返回",-1),g=a("",1);function y(F,o,u,_,C,c){const n=l("y");return e(),t("div",null,[d,i("p",null,[r,s(": str: 设置后的插件名称 "),k(n,null,{default:p(()=>[s("name")]),_:1})]),g])}const A=h(E,[["render",y]]);export{B as __pageData,A as default};

View File

@ -0,0 +1 @@
import{_ as t,c as i,o as n,j as e,a}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.plugin.manager","description":"","frontmatter":{"title":"liteyuki.plugin.manager"},"headers":[],"relativePath":"dev/api/plugin/manager.md","filePath":"zh/dev/api/plugin/manager.md","lastUpdated":null}'),r={name:"dev/api/plugin/manager.md"},o=e("h1",{id:"liteyuki-plugin-manager",tabindex:"-1"},[a("liteyuki.plugin.manager "),e("a",{class:"header-anchor",href:"#liteyuki-plugin-manager","aria-label":'Permalink to "liteyuki.plugin.manager"'},"")],-1),l=e("p",null,"Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved",-1),s=e("p",null,[a("@Time : 2024/7/23 下午11:59 @Author : snowykami @Email : "),e("a",{href:"mailto:snowykami@outlook.com",target:"_blank",rel:"noreferrer"},"snowykami@outlook.com"),a(" @File : manager.py @Software: PyCharm")],-1),m=[o,l,s];function p(u,d,c,g,_,h){return n(),i("div",null,m)}const f=t(r,[["render",p]]);export{y as __pageData,f as default};

View File

@ -0,0 +1 @@
import{_ as t,c as i,o as n,j as e,a}from"./chunks/framework.C4_mTacX.js";const y=JSON.parse('{"title":"liteyuki.plugin.manager","description":"","frontmatter":{"title":"liteyuki.plugin.manager"},"headers":[],"relativePath":"dev/api/plugin/manager.md","filePath":"zh/dev/api/plugin/manager.md","lastUpdated":null}'),r={name:"dev/api/plugin/manager.md"},o=e("h1",{id:"liteyuki-plugin-manager",tabindex:"-1"},[a("liteyuki.plugin.manager "),e("a",{class:"header-anchor",href:"#liteyuki-plugin-manager","aria-label":'Permalink to "liteyuki.plugin.manager"'},"")],-1),l=e("p",null,"Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved",-1),s=e("p",null,[a("@Time : 2024/7/23 下午11:59 @Author : snowykami @Email : "),e("a",{href:"mailto:snowykami@outlook.com",target:"_blank",rel:"noreferrer"},"snowykami@outlook.com"),a(" @File : manager.py @Software: PyCharm")],-1),m=[o,l,s];function p(u,d,c,g,_,h){return n(),i("div",null,m)}const f=t(r,[["render",p]]);export{y as __pageData,f as default};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
import{_ as a,c as t,o as e,a9 as r}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.plugin.model","description":"","frontmatter":{"title":"liteyuki.plugin.model"},"headers":[],"relativePath":"dev/api/plugin/model.md","filePath":"zh/dev/api/plugin/model.md","lastUpdated":null}'),o={name:"dev/api/plugin/model.md"},s=r("",25),i=[s];function l(n,d,h,c,u,m){return e(),t("div",null,i)}const k=a(o,[["render",l]]);export{g as __pageData,k as default};

View File

@ -0,0 +1,7 @@
import{_ as i,c as s,o as t,a9 as a}from"./chunks/framework.C4_mTacX.js";const k=JSON.parse('{"title":"liteyuki.plugin","description":"","frontmatter":{"title":"liteyuki.plugin","collapsed":true},"headers":[],"relativePath":"dev/api/plugin/plugin.md","filePath":"zh/dev/api/plugin/plugin.md","lastUpdated":null}'),n={name:"dev/api/plugin/plugin.md"},e=a(`<h1 id="liteyuki-plugin" tabindex="-1">liteyuki.plugin <a class="header-anchor" href="#liteyuki-plugin" aria-label="Permalink to &quot;liteyuki.plugin&quot;"></a></h1><h3 id="func-get-loaded-plugins-dict-str-plugin" tabindex="-1"><em><strong>func</strong></em> <code>get_loaded_plugins() -&gt; dict[str, Plugin]</code> <a class="header-anchor" href="#func-get-loaded-plugins-dict-str-plugin" aria-label="Permalink to &quot;***func*** \`get_loaded_plugins() -&gt; dict[str, Plugin]\`&quot;"></a></h3><p><strong>说明</strong>: 获取已加载的插件</p><p><strong>返回</strong>: dict[str, Plugin]: 插件字典</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/plugin/__init__.py#L13" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> get_loaded_plugins</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">() -&gt; dict[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, Plugin]:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 获取已加载的插件</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> Returns:</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> dict[str, Plugin]: 插件字典</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> _plugins</span></span></code></pre></div></details>`,5),l=[e];function p(d,u,r,h,o,g){return t(),s("div",null,l)}const _=i(n,[["render",p]]);export{k as __pageData,_ as default};

View File

@ -0,0 +1 @@
import{_ as i,c as s,o as t,a9 as a}from"./chunks/framework.C4_mTacX.js";const k=JSON.parse('{"title":"liteyuki.plugin","description":"","frontmatter":{"title":"liteyuki.plugin","collapsed":true},"headers":[],"relativePath":"dev/api/plugin/plugin.md","filePath":"zh/dev/api/plugin/plugin.md","lastUpdated":null}'),n={name:"dev/api/plugin/plugin.md"},e=a("",5),l=[e];function p(d,u,r,h,o,g){return t(),s("div",null,l)}const _=i(n,[["render",p]]);export{k as __pageData,_ as default};

View File

@ -0,0 +1 @@
import{_ as i,c as t,o as s,j as e,a as l}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.plugins","description":"","frontmatter":{"title":"liteyuki.plugins","collapsed":true},"headers":[],"relativePath":"dev/api/plugins/index.md","filePath":"zh/dev/api/plugins/index.md","lastUpdated":null}'),a={name:"dev/api/plugins/index.md"},n=e("h1",{id:"liteyuki-plugins",tabindex:"-1"},[l("liteyuki.plugins "),e("a",{class:"header-anchor",href:"#liteyuki-plugins","aria-label":'Permalink to "liteyuki.plugins"'},"")],-1),o=e("p",null,"此模块为内置插件文件夹,用于存放内置插件。 This module is the built-in plugin folder, used to store built-in plugins.",-1),d=[n,o];function u(p,r,c,_,h,g){return s(),t("div",null,d)}const k=i(a,[["render",u]]);export{f as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as i,c as t,o as s,j as e,a as l}from"./chunks/framework.C4_mTacX.js";const f=JSON.parse('{"title":"liteyuki.plugins","description":"","frontmatter":{"title":"liteyuki.plugins","collapsed":true},"headers":[],"relativePath":"dev/api/plugins/index.md","filePath":"zh/dev/api/plugins/index.md","lastUpdated":null}'),a={name:"dev/api/plugins/index.md"},n=e("h1",{id:"liteyuki-plugins",tabindex:"-1"},[l("liteyuki.plugins "),e("a",{class:"header-anchor",href:"#liteyuki-plugins","aria-label":'Permalink to "liteyuki.plugins"'},"")],-1),o=e("p",null,"此模块为内置插件文件夹,用于存放内置插件。 This module is the built-in plugin folder, used to store built-in plugins.",-1),d=[n,o];function u(p,r,c,_,h,g){return s(),t("div",null,d)}const k=i(a,[["render",u]]);export{f as __pageData,k as default};

View File

@ -0,0 +1 @@
import{_ as e,c as i,o as s,a9 as t}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.plugins.liteecho","description":"","frontmatter":{"title":"liteyuki.plugins.liteecho"},"headers":[],"relativePath":"dev/api/plugins/liteecho.md","filePath":"zh/dev/api/plugins/liteecho.md","lastUpdated":null}'),a={name:"dev/api/plugins/liteecho.md"},l=t('<h1 id="liteyuki-plugins-liteecho" tabindex="-1">liteyuki.plugins.liteecho <a class="header-anchor" href="#liteyuki-plugins-liteecho" aria-label="Permalink to &quot;liteyuki.plugins.liteecho&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/8/22 下午12:31 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : liteecho.py @Software: PyCharm</p><p><code>@on_startswith([&#39;liteecho&#39;], rule=is_su_rule).handle()</code></p><h3 id="async-func-liteecho-event-messageevent" tabindex="-1"><em><strong>async func</strong></em> <code>liteecho(event: MessageEvent)</code> <a class="header-anchor" href="#async-func-liteecho-event-messageevent" aria-label="Permalink to &quot;***async func*** `liteecho(event: MessageEvent)`&quot;"></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/plugins/liteecho.py#L18" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@on_startswith</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">([</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;liteecho&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">rule</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">is_su_rule)</span><span style="--shiki-light:#B31D28;--shiki-dark:#FDAEB7;--shiki-light-font-style:italic;--shiki-dark-font-style:italic;">.handle()</span></span>\n<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> liteecho</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(event: MessageEvent):</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event.reply(event.raw_message.strip()[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:].strip())</span></span></code></pre></div></details>',6),n=[l];function h(o,p,r,k,c,d){return s(),i("div",null,n)}const y=e(a,[["render",h]]);export{g as __pageData,y as default};

View File

@ -0,0 +1 @@
import{_ as e,c as i,o as s,a9 as t}from"./chunks/framework.C4_mTacX.js";const g=JSON.parse('{"title":"liteyuki.plugins.liteecho","description":"","frontmatter":{"title":"liteyuki.plugins.liteecho"},"headers":[],"relativePath":"dev/api/plugins/liteecho.md","filePath":"zh/dev/api/plugins/liteecho.md","lastUpdated":null}'),a={name:"dev/api/plugins/liteecho.md"},l=t("",6),n=[l];function h(o,p,r,k,c,d){return s(),i("div",null,n)}const y=e(a,[["render",h]]);export{g as __pageData,y as default};

View File

@ -0,0 +1,8 @@
import{_ as i,c as s,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const _=JSON.parse('{"title":"liteyuki.plugins.plugin_loader","description":"","frontmatter":{"title":"liteyuki.plugins.plugin_loader","collapsed":true},"headers":[],"relativePath":"dev/api/plugins/plugin_loader/index.md","filePath":"zh/dev/api/plugins/plugin_loader/index.md","lastUpdated":null}'),l={name:"dev/api/plugins/plugin_loader/index.md"},t=n(`<h1 id="liteyuki-plugins-plugin-loader" tabindex="-1">liteyuki.plugins.plugin_loader <a class="header-anchor" href="#liteyuki-plugins-plugin-loader" aria-label="Permalink to &quot;liteyuki.plugins.plugin_loader&quot;"></a></h1><p>Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved</p><p>@Time : 2024/8/11 下午10:02 @Author : snowykami @Email : <a href="mailto:snowykami@outlook.com" target="_blank" rel="noreferrer">snowykami@outlook.com</a> @File : <strong>init</strong>.py.py @Software: PyCharm</p><h3 id="func-default-plugins-loader" tabindex="-1"><em><strong>func</strong></em> <code>default_plugins_loader()</code> <a class="header-anchor" href="#func-default-plugins-loader" aria-label="Permalink to &quot;***func*** \`default_plugins_loader()\`&quot;"></a></h3><p><strong>说明</strong>: 默认插件加载器,应在初始化时调用</p><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/LiteyukiBot/tree/main/liteyuki/plugins/plugin_loader/__init__.py#L21" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> default_plugins_loader</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 默认插件加载器应在初始化时调用</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;&quot;&quot;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugin </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_config(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;liteyuki.plugins&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, []):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_plugin(plugin)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plugin_dir </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_config(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;liteyuki.plugin_dirs&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;src/liteyuki_plugins&#39;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_plugins(plugin_dir)</span></span></code></pre></div></details>`,6),e=[t];function p(h,r,o,d,k,u){return a(),s("div",null,e)}const c=i(l,[["render",p]]);export{_ as __pageData,c as default};

View File

@ -0,0 +1 @@
import{_ as i,c as s,o as a,a9 as n}from"./chunks/framework.C4_mTacX.js";const _=JSON.parse('{"title":"liteyuki.plugins.plugin_loader","description":"","frontmatter":{"title":"liteyuki.plugins.plugin_loader","collapsed":true},"headers":[],"relativePath":"dev/api/plugins/plugin_loader/index.md","filePath":"zh/dev/api/plugins/plugin_loader/index.md","lastUpdated":null}'),l={name:"dev/api/plugins/plugin_loader/index.md"},t=n("",6),e=[t];function p(h,r,o,d,k,u){return a(),s("div",null,e)}const c=i(l,[["render",p]]);export{_ as __pageData,c as default};

Some files were not shown because too many files have changed in this diff Show More