forked from bot/app
Compare commits
No commits in common. "main" and "docs" have entirely different histories.
53
.github/ISSUE_TEMPLATE/问题反馈.md
vendored
53
.github/ISSUE_TEMPLATE/问题反馈.md
vendored
@ -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`的输出,以及其他相关信息,以及你的建议
|
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@ -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"
|
44
.github/workflows/ISSUE_TEMPLATE.md
vendored
44
.github/workflows/ISSUE_TEMPLATE.md
vendored
@ -1,44 +0,0 @@
|
||||
# 问题反馈
|
||||
|
||||
## **请确保**
|
||||
|
||||
- 已认真阅读[文档]("https://bot.liteyuki.icu"),该问题不是文档提及的或你自己操作不当造成的
|
||||
- 你的问题是在最新版本的代码上测试的
|
||||
- 请勿重复提交相同或类似的issue
|
||||
|
||||
|
||||
## **描述问题**
|
||||
|
||||
请在此简单描述问题
|
||||
|
||||
|
||||
|
||||
## **如何复现**
|
||||
|
||||
请阐述一下如何重现这个问题
|
||||
### 预期
|
||||
|
||||
描述你期望发生的事情
|
||||
|
||||
### 实际
|
||||
|
||||
描述实际发生的事情
|
||||
|
||||
|
||||
|
||||
## **日志或截图**
|
||||
```
|
||||
日志内容
|
||||
```
|
||||
|
||||
|
||||
## **设备信息**
|
||||
- **系统**: [例如 Ubuntu 22.04]
|
||||
- **CPU**: [例如 Intel i7-7700K]
|
||||
- **内存**: [例如 16GB]
|
||||
- **Python**: [例如CPython 3.10.7]
|
||||
|
||||
|
||||
**补充内容**
|
||||
|
||||
可选,推荐提供`pip freeze`的输出,以及其他相关信息,以及你的建议
|
70
.github/workflows/deploy-docs.yml
vendored
70
.github/workflows/deploy-docs.yml
vendored
@ -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
|
20
.github/workflows/pypi-publish.yml
vendored
20
.github/workflows/pypi-publish.yml
vendored
@ -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
67
.gitignore
vendored
@ -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
|
19
Dockerfile
19
Dockerfile
@ -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
31
LICENSE
@ -1,31 +0,0 @@
|
||||
LSO license
|
||||
LiteyukiStudio Opensource license
|
||||
|
||||
---
|
||||
|
||||
版权所有 © 2024 Snowykami
|
||||
|
||||
---
|
||||
|
||||
免费向任何获得副本的人或组织授予以相同许可为基础的权利
|
||||
|
||||
包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件的副本
|
||||
|
||||
本软件及相关文档文件(以下简称"本软件")在相同方式许可为基础, 以开源的形式发布于互联网抑或其他媒体介质平台
|
||||
|
||||
任何人都有权利获取副本并以上述方式获取许可传播和/或使用
|
||||
|
||||
但获取副本时仍需注意:
|
||||
|
||||
- 上述版权声明和本许可声明应包含在本软件的副本中
|
||||
- 使用本软件及其副本时仍需保持与原有形式相同
|
||||
|
||||
- 在使用时仍需将本软件的副本以相同许可公开表现:
|
||||
- 不得未经原作者允许将本软件的副本以非原许可的形式对外盈利
|
||||
|
||||
---
|
||||
|
||||
该软件按"原样"之副本提供,不提供任何形式的任意保证,明示或暗示:
|
||||
包括但不限于适销性保证, 适用于特定目的非侵权
|
||||
|
||||
在任何情况下, 作者或版权所有者对任何非因作者或版权所有者使用该软件造成的索赔、损害或其他责任, 无论是在合同诉讼、侵权行为还是其他诉讼中都不具有责任, 作者及其版权所有者有权利驳回使用者因个人原因造成的任何损失之赔付
|
51
README.md
51
README.md
@ -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
1
assets/app.CWfxCzjM.js
Normal 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};
|
1
assets/chunks/@localSearchIndexen.B5evk3Gc.js
Normal file
1
assets/chunks/@localSearchIndexen.B5evk3Gc.js
Normal file
File diff suppressed because one or more lines are too long
1
assets/chunks/@localSearchIndexroot.CrswBkz6.js
Normal file
1
assets/chunks/@localSearchIndexroot.CrswBkz6.js
Normal file
File diff suppressed because one or more lines are too long
7
assets/chunks/VPLocalSearchBox.DWIkN3b9.js
Normal file
7
assets/chunks/VPLocalSearchBox.DWIkN3b9.js
Normal file
File diff suppressed because one or more lines are too long
17
assets/chunks/framework.C4_mTacX.js
Normal file
17
assets/chunks/framework.C4_mTacX.js
Normal file
File diff suppressed because one or more lines are too long
11
assets/chunks/theme.BleEYWi4.js
Normal file
11
assets/chunks/theme.BleEYWi4.js
Normal file
File diff suppressed because one or more lines are too long
31
assets/deploy_config.md.BBoJ_SVs.js
Normal file
31
assets/deploy_config.md.BBoJ_SVs.js
Normal 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 "配置""></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 "**基础配置项**""></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;">"/"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">""</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ] </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 指令前缀,若没有""空命令头,请开启alconna_use_command_start保证alconna解析正常</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;">"liteyuki"</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;">"1919810"</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;">"INFO"</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 "**其他配置**""></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;">""</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;">"zh-CN"</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;"> # alconna是否自动补全指令,默认false,建议开启</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;">"custom_value1"</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;">"custom_value2"</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="示例-与nonebot对接的onebot实现端配置" tabindex="-1"><strong>示例:与NoneBot对接的OneBot实现端配置</strong> <a class="header-anchor" href="#示例-与nonebot对接的onebot实现端配置" aria-label="Permalink to "**示例:与NoneBot对接的OneBot实现端配置**""></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>""</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 "**其他**""></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};
|
1
assets/deploy_config.md.BBoJ_SVs.lean.js
Normal file
1
assets/deploy_config.md.BBoJ_SVs.lean.js
Normal 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};
|
1
assets/deploy_fandq.md.D3AaSKzf.js
Normal file
1
assets/deploy_fandq.md.D3AaSKzf.js
Normal file
File diff suppressed because one or more lines are too long
1
assets/deploy_fandq.md.D3AaSKzf.lean.js
Normal file
1
assets/deploy_fandq.md.D3AaSKzf.lean.js
Normal 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};
|
8
assets/deploy_install.md.DJmVueGv.js
Normal file
8
assets/deploy_install.md.DJmVueGv.js
Normal 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 "安装""></a></h1><h2 id="常规部署" tabindex="-1"><strong>常规部署</strong> <a class="header-anchor" href="#常规部署" aria-label="Permalink to "**常规部署**""></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 "**使用Docker构建**""></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 "**使用TRSS Scripts部署**""></a></h2><p><a href="https://timerainstarsky.github.io/TRSS_Liteyuki/" target="_blank" rel="noreferrer">TRSS_Liteyuki轻雪机器人管理脚本</a>,该功能由TRSS提供支持,不是LiteyukiBot官方提供的功能,推荐使用<code>Arch Linux</code></p><h2 id="装置要求" tabindex="-1"><strong>装置要求</strong> <a class="header-anchor" href="#装置要求" aria-label="Permalink to "**装置要求**""></a></h2><ul><li>Windows系统版本最低<code>Windows10+</code>/<code>Windows Server 2019+</code></li><li>Linux系统要支持Python3.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>轻雪的更新功能依赖Git,如果你没有安装Git直接下载源代码运行,你将无法使用更新功能</p></div><h4 id="其他问题请移步至答疑" tabindex="-1">其他问题请移步至<a href="./fandq.html">答疑</a> <a class="header-anchor" href="#其他问题请移步至答疑" aria-label="Permalink to "其他问题请移步至[答疑](./fandq)""></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};
|
1
assets/deploy_install.md.DJmVueGv.lean.js
Normal file
1
assets/deploy_install.md.DJmVueGv.lean.js
Normal 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};
|
1
assets/dev_api_api.md.Co6Tvpsf.js
Normal file
1
assets/dev_api_api.md.Co6Tvpsf.js
Normal 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 "liteyuki""></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 "var `__version__`""></a></h3><ul><li><p><strong>说明</strong>: 测试版本号</p></li><li><p><strong>默认值</strong>: <code>'6.3.10'</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};
|
1
assets/dev_api_api.md.Co6Tvpsf.lean.js
Normal file
1
assets/dev_api_api.md.Co6Tvpsf.lean.js
Normal 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};
|
181
assets/dev_api_bot_bot.md.BICj4NaL.js
Normal file
181
assets/dev_api_bot_bot.md.BICj4NaL.js
Normal 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 "liteyuki.bot""></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 "***class*** \`LiteyukiBot\`""></a></h3><h4 id="func-init-self-kwargs-none" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, **kwargs) -> None</code> <a class="header-anchor" href="#func-init-self-kwargs-none" aria-label="Permalink to "***func*** \`__init__(self, **kwargs) -> None\`""></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) -> </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;"> """</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;"> """</span></span>
|
||||
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> '常规操作'</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;"> '配置'</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;"> '初始化'</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;">'Liteyuki is initializing...'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> '生命周期管理'</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;"> '事件循环'</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;"> '加载插件加载器'</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_plugin(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'liteyuki.plugins.plugin_loader'</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 "***func*** \`run(self)\`""></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;"> """</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:#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;">'<y>Liteyuki is stopping...</y>'</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;">'<y>Liteyuki is stopped...</y>'</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 "***async func*** \`keep_alive(self)\`""></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;"> """</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:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Liteyuki is keeping alive...'</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;">'Liteyuki is exiting...'</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 "***func*** \`restart(self, delay: int = 0)\`""></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;"> """</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;"> """</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;"><</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;">'Restarting LiteyukiBot...'</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;"> 'Windows'</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;"> 'start'</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;"> 'Linux'</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;"> 'nohup'</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;"> 'Darwin'</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;"> 'open'</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;"> 'nohup'</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;">"</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;">' '</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;">"</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 "***func*** \`restart_process(self, name: Optional[str] = None)\`""></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;"> """</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;"> """</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;">'</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'</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;">'</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'</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 "***func*** \`init(self, *args, **kwargs)\`""></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;"> """</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;"> """</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 "***func*** \`init_logger(self)\`""></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;"> """</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:#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 "***func*** \`stop(self)\`""></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;"> """</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:#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) -> LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to "***func*** \`on_before_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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 "***func*** \`on_after_start(self, func: LIFESPAN_FUNC)\`""></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;"> """</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;"> """</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 "***func*** \`on_after_shutdown(self, func: LIFESPAN_FUNC)\`""></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;"> """</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;"> """</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 "***func*** \`on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC)\`""></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;"> """</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;"> """</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) -> 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 "***func*** \`on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -> PROCESS_LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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 "***func*** \`on_after_restart(self, func: LIFESPAN_FUNC)\`""></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;"> """</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;"> """</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() -> LiteyukiBot</code> <a class="header-anchor" href="#func-get-bot-liteyukibot" aria-label="Permalink to "***func*** \`get_bot() -> LiteyukiBot\`""></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;">() -> LiteyukiBot:</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;"> 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;"> """</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;">'Liteyuki instance not initialized.'</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;">"Can't get bot instance in sub process."</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) -> Any</code> <a class="header-anchor" href="#func-get-config-key-str-default-any-none-any" aria-label="Permalink to "***func*** \`get_config(key: str, default: Any = None) -> Any\`""></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;">) -> Any:</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;"> 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;"> """</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) -> 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 "***func*** \`get_config_with_compat(key: str, compat_keys: tuple[str], default: Any = None) -> Any\`""></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;">) -> Any:</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;"> 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;"> """</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;">'Config key "</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;">" will be deprecated, use "</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;">" instead.'</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};
|
1
assets/dev_api_bot_bot.md.BICj4NaL.lean.js
Normal file
1
assets/dev_api_bot_bot.md.BICj4NaL.lean.js
Normal 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};
|
181
assets/dev_api_bot_index.md.CO6VsP4-.js
Normal file
181
assets/dev_api_bot_index.md.CO6VsP4-.js
Normal 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 "liteyuki.bot""></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 "***class*** \`LiteyukiBot\`""></a></h3><h4 id="func-init-self-kwargs-none" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self, **kwargs) -> None</code> <a class="header-anchor" href="#func-init-self-kwargs-none" aria-label="Permalink to "***func*** \`__init__(self, **kwargs) -> None\`""></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) -> </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;"> """</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;"> """</span></span>
|
||||
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> '常规操作'</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;"> '配置'</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;"> '初始化'</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;">'Liteyuki is initializing...'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> '生命周期管理'</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;"> '事件循环'</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;"> '加载插件加载器'</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> load_plugin(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'liteyuki.plugins.plugin_loader'</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 "***func*** \`run(self)\`""></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;"> """</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:#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;">'<y>Liteyuki is stopping...</y>'</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;">'<y>Liteyuki is stopped...</y>'</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 "***async func*** \`keep_alive(self)\`""></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;"> """</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:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Liteyuki is keeping alive...'</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;">'Liteyuki is exiting...'</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 "***func*** \`restart(self, delay: int = 0)\`""></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;"> """</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;"> """</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;"><</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;">'Restarting LiteyukiBot...'</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;"> 'Windows'</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;"> 'start'</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;"> 'Linux'</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;"> 'nohup'</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;"> 'Darwin'</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;"> 'open'</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;"> 'nohup'</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;">"</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;">' '</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;">"</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 "***func*** \`restart_process(self, name: Optional[str] = None)\`""></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;"> """</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;"> """</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;">'</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'</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;">'</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'</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 "***func*** \`init(self, *args, **kwargs)\`""></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;"> """</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;"> """</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 "***func*** \`init_logger(self)\`""></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;"> """</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:#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 "***func*** \`stop(self)\`""></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;"> """</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:#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) -> LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to "***func*** \`on_before_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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 "***func*** \`on_after_start(self, func: LIFESPAN_FUNC)\`""></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;"> """</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;"> """</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 "***func*** \`on_after_shutdown(self, func: LIFESPAN_FUNC)\`""></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;"> """</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;"> """</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 "***func*** \`on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC)\`""></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;"> """</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;"> """</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) -> 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 "***func*** \`on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -> PROCESS_LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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 "***func*** \`on_after_restart(self, func: LIFESPAN_FUNC)\`""></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;"> """</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;"> """</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() -> LiteyukiBot</code> <a class="header-anchor" href="#func-get-bot-liteyukibot" aria-label="Permalink to "***func*** \`get_bot() -> LiteyukiBot\`""></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;">() -> LiteyukiBot:</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;"> 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;"> """</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;">'Liteyuki instance not initialized.'</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;">"Can't get bot instance in sub process."</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) -> Any</code> <a class="header-anchor" href="#func-get-config-key-str-default-any-none-any" aria-label="Permalink to "***func*** \`get_config(key: str, default: Any = None) -> Any\`""></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;">) -> Any:</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;"> 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;"> """</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) -> 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 "***func*** \`get_config_with_compat(key: str, compat_keys: tuple[str], default: Any = None) -> Any\`""></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;">) -> Any:</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;"> 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;"> """</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;">'Config key "</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;">" will be deprecated, use "</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;">" instead.'</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};
|
1
assets/dev_api_bot_index.md.CO6VsP4-.lean.js
Normal file
1
assets/dev_api_bot_index.md.CO6VsP4-.lean.js
Normal 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};
|
104
assets/dev_api_bot_lifespan.md.Brz5v0DB.js
Normal file
104
assets/dev_api_bot_lifespan.md.Brz5v0DB.js
Normal 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 "liteyuki.bot.lifespan""></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 "var \`SYNC_LIFESPAN_FUNC\`""></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 "var \`ASYNC_LIFESPAN_FUNC\`""></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 "var \`LIFESPAN_FUNC\`""></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 "var \`SYNC_PROCESS_LIFESPAN_FUNC\`""></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 "var \`ASYNC_PROCESS_LIFESPAN_FUNC\`""></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 "var \`PROCESS_LIFESPAN_FUNC\`""></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 "***class*** \`Lifespan\`""></a></h3><h4 id="func-init-self-none" tabindex="-1"><em><strong>func</strong></em> <code>__init__(self) -> None</code> <a class="header-anchor" href="#func-init-self-none" aria-label="Permalink to "***func*** \`__init__(self) -> None\`""></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) -> </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;"> """</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:#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) -> 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 "***async func*** \`run_funcs(funcs: Sequence[LIFESPAN_FUNC | PROCESS_LIFESPAN_FUNC], *args, **kwargs) -> None\`""></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) -> </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;"> """</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;"> """</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) -> LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-before-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to "***func*** \`on_before_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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) -> LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-after-start-self-func-lifespan-func-lifespan-func" aria-label="Permalink to "***func*** \`on_after_start(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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) -> 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 "***func*** \`on_before_process_shutdown(self, func: PROCESS_LIFESPAN_FUNC) -> PROCESS_LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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) -> LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-after-shutdown-self-func-lifespan-func-lifespan-func" aria-label="Permalink to "***func*** \`on_after_shutdown(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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) -> 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 "***func*** \`on_before_process_restart(self, func: PROCESS_LIFESPAN_FUNC) -> PROCESS_LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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) -> LIFESPAN_FUNC</code> <a class="header-anchor" href="#func-on-after-restart-self-func-lifespan-func-lifespan-func" aria-label="Permalink to "***func*** \`on_after_restart(self, func: LIFESPAN_FUNC) -> LIFESPAN_FUNC\`""></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;">) -> </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;"> """</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;"> """</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) -> None</code> <a class="header-anchor" href="#async-func-before-start-self-none" aria-label="Permalink to "***async func*** \`before_start(self) -> None\`""></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) -> </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;"> """</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:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Running before_start functions'</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) -> None</code> <a class="header-anchor" href="#async-func-after-start-self-none" aria-label="Permalink to "***async func*** \`after_start(self) -> None\`""></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) -> </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;"> """</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:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Running after_start functions'</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) -> None</code> <a class="header-anchor" href="#async-func-before-process-shutdown-self-args-kwargs-none" aria-label="Permalink to "***async func*** \`before_process_shutdown(self, *args, **kwargs) -> None\`""></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) -> </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;"> """</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:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Running before_shutdown functions'</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) -> None</code> <a class="header-anchor" href="#async-func-after-shutdown-self-none" aria-label="Permalink to "***async func*** \`after_shutdown(self) -> None\`""></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) -> </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;"> """</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:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Running after_shutdown functions'</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) -> None</code> <a class="header-anchor" href="#async-func-before-process-restart-self-args-kwargs-none" aria-label="Permalink to "***async func*** \`before_process_restart(self, *args, **kwargs) -> None\`""></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) -> </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;"> """</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:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Running before_restart functions'</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) -> None</code> <a class="header-anchor" href="#async-func-after-restart-self-none" aria-label="Permalink to "***async func*** \`after_restart(self) -> None\`""></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) -> </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;"> """</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:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Running after_restart functions'</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};
|
1
assets/dev_api_bot_lifespan.md.Brz5v0DB.lean.js
Normal file
1
assets/dev_api_bot_lifespan.md.Brz5v0DB.lean.js
Normal 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};
|
145
assets/dev_api_comm_channel.md.DqKQ48r8.js
Normal file
145
assets/dev_api_comm_channel.md.DqKQ48r8.js
Normal file
File diff suppressed because one or more lines are too long
1
assets/dev_api_comm_channel.md.DqKQ48r8.lean.js
Normal file
1
assets/dev_api_comm_channel.md.DqKQ48r8.lean.js
Normal 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};
|
1
assets/dev_api_comm_comm.md.DoFxOyxg.js
Normal file
1
assets/dev_api_comm_comm.md.DoFxOyxg.js
Normal 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};
|
1
assets/dev_api_comm_comm.md.DoFxOyxg.lean.js
Normal file
1
assets/dev_api_comm_comm.md.DoFxOyxg.lean.js
Normal 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};
|
1
assets/dev_api_comm_event.md.CKj2UKdm.js
Normal file
1
assets/dev_api_comm_event.md.CKj2UKdm.js
Normal 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 "liteyuki.comm.event""></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 "***class*** `Event`""></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 "***func*** `__init__(self, name: str, data: dict[str, Any])`""></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};
|
1
assets/dev_api_comm_event.md.CKj2UKdm.lean.js
Normal file
1
assets/dev_api_comm_event.md.CKj2UKdm.lean.js
Normal 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};
|
1
assets/dev_api_comm_index.md.uufyI1S9.js
Normal file
1
assets/dev_api_comm_index.md.uufyI1S9.js
Normal 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};
|
1
assets/dev_api_comm_index.md.uufyI1S9.lean.js
Normal file
1
assets/dev_api_comm_index.md.uufyI1S9.lean.js
Normal 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};
|
1
assets/dev_api_comm_rpc.md.DZB2wFct.js
Normal file
1
assets/dev_api_comm_rpc.md.DZB2wFct.js
Normal 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 "liteyuki.comm.rpc""></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 "***class*** `RPC`""></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) -> None</code> <a class="header-anchor" href="#func-init-self-on-calling-on-calling-func-none" aria-label="Permalink to "***func*** `__init__(self, on_calling: ON_CALLING_FUNC) -> None`""></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;">) -> </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) -> Any</code> <a class="header-anchor" href="#func-call-self-args-tuple-kwargs-dict-any" aria-label="Permalink to "***func*** `call(self, args: tuple, kwargs: dict) -> Any`""></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;">) -> Any:</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;"> 调用</span></span>\n<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> """</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};
|
1
assets/dev_api_comm_rpc.md.DZB2wFct.lean.js
Normal file
1
assets/dev_api_comm_rpc.md.DZB2wFct.lean.js
Normal 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};
|
26
assets/dev_api_comm_socks_channel.md.D_LOQMVo.js
Normal file
26
assets/dev_api_comm_socks_channel.md.D_LOQMVo.js
Normal 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 "liteyuki.comm.socks_channel""></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 "***class*** \`SocksChannel\`""></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 "***func*** \`__init__(self, name: str)\`""></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;"> """</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;"> """</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 "***func*** \`send(self, data)\`""></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;"> """</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;"> """</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 "***func*** \`receive(self)\`""></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;"> """</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;"> """</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 "***func*** \`close(self)\`""></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;"> """</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:#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};
|
1
assets/dev_api_comm_socks_channel.md.D_LOQMVo.lean.js
Normal file
1
assets/dev_api_comm_socks_channel.md.D_LOQMVo.lean.js
Normal 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};
|
144
assets/dev_api_comm_storage.md.ByeStviG.js
Normal file
144
assets/dev_api_comm_storage.md.ByeStviG.js
Normal 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 "liteyuki.comm.storage""></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 "var \`_on_main_subscriber_receive_funcs\`""></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 "var \`_on_sub_subscriber_receive_funcs\`""></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 "***class*** \`KeyValueStore\`""></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 "***func*** \`__init__(self)\`""></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;">'shared_memory-active'</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;">'shared_memory-passive'</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;">'shared_memory-publish'</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) -> None</code> <a class="header-anchor" href="#func-set-self-key-str-value-any-none" aria-label="Permalink to "***func*** \`set(self, key: str, value: Any) -> None\`""></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) -> </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;"> """</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;"> """</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;">'set'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'key'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: key, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'value'</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) -> Optional[Any]</code> <a class="header-anchor" href="#func-get-self-key-str-default-optional-any-none-optional-any" aria-label="Permalink to "***func*** \`get(self, key: str, default: Optional[Any] = None) -> Optional[Any]\`""></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;">) -> Optional[Any]:</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;"> 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;"> """</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;">'recv_chan'</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;">'get'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'key'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: key, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'default'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: default, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'recv_chan'</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) -> None</code> <a class="header-anchor" href="#func-delete-self-key-str-ignore-key-error-bool-true-none" aria-label="Permalink to "***func*** \`delete(self, key: str, ignore_key_error: bool = True) -> None\`""></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;">) -> </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;"> """</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;"> """</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;">'delete'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'key'</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) -> dict[str, Any]</code> <a class="header-anchor" href="#func-get-all-self-dict-str-any" aria-label="Permalink to "***func*** \`get_all(self) -> dict[str, Any]\`""></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) -> 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;"> """</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;"> """</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;">'recv_chan'</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;">'get_all'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'recv_chan'</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) -> None</code> <a class="header-anchor" href="#func-publish-self-channel-str-data-any-none" aria-label="Permalink to "***func*** \`publish(self, channel_: str, data: Any) -> None\`""></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) -> </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;"> """</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;"> """</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;">'publish'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, {</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'channel'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: channel_, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'data'</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) -> 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 "***func*** \`on_subscriber_receive(self, channel_: str) -> Callable[[ON_RECEIVE_FUNC], ON_RECEIVE_FUNC]\`""></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;">) -> 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;"> """</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;"> """</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;">'Cannot subscribe in sub process.'</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;">) -> </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 "***async func*** \`run_subscriber_receive_funcs(channel_: str, data: Any)\`""></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;"> """</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;"> """</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 "***async func*** \`start_receive_loop(self)\`""></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;"> """</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:#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;">'Cannot start receive loop in sub process.'</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;"> 'publish'</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;">'channel'</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;">'data'</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 "***class*** \`GlobalKeyValueStore\`""></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 "***func*** \`get_instance(cls)\`""></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 "***attr*** \`_instance = None\`""></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 "***attr*** \`_lock = threading.Lock()\`""></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 "var \`shared_memory\`""></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 "var \`_ref_count\`""></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] == 'get')</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 "***func*** \`on_get(data: tuple[str, dict[str, Any]])\`""></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;"> 'get'</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;">'key'</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;">'default'</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;">'recv_chan'</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] == 'set')</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 "***func*** \`on_set(data: tuple[str, dict[str, Any]])\`""></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;"> 'set'</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;">'key'</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;">'value'</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] == 'delete')</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 "***func*** \`on_delete(data: tuple[str, dict[str, Any]])\`""></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;"> 'delete'</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;">'key'</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] == 'get_all')</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 "***func*** \`on_get_all(data: tuple[str, dict[str, Any]])\`""></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;"> 'get_all'</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;">'recv_chan'</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};
|
1
assets/dev_api_comm_storage.md.ByeStviG.lean.js
Normal file
1
assets/dev_api_comm_storage.md.ByeStviG.lean.js
Normal 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};
|
77
assets/dev_api_config.md.B6-1F5M4.js
Normal file
77
assets/dev_api_config.md.B6-1F5M4.js
Normal 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 "liteyuki.config""></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]) -> dict[str, Any]</code> <a class="header-anchor" href="#func-flat-config-config-dict-str-any-dict-str-any" aria-label="Permalink to "***func*** `flat_config(config: dict[str, Any]) -> dict[str, Any]`""></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]) -> 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;"> """</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}}} -> {"a.b.c": 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;"> """</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;">'</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;">'</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) -> dict[str, Any]</code> <a class="header-anchor" href="#func-load-from-yaml-file-str-dict-str-any" aria-label="Permalink to "***func*** \`load_from_yaml(file_: str) -> dict[str, Any]\`""></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;">) -> 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;"> """</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;"> """</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;">'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;">'</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;">'r'</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;">'utf-8'</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) -> dict[str, Any]</code> <a class="header-anchor" href="#func-load-from-json-file-str-dict-str-any" aria-label="Permalink to "***func*** \`load_from_json(file_: str) -> dict[str, Any]\`""></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;">) -> 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;"> """</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;"> """</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;">'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;">'</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;">'r'</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;">'utf-8'</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) -> dict[str, Any]</code> <a class="header-anchor" href="#func-load-from-toml-file-str-dict-str-any" aria-label="Permalink to "***func*** \`load_from_toml(file_: str) -> dict[str, Any]\`""></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;">) -> 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;"> """</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;"> """</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;">'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;">'</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;">'r'</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;">'utf-8'</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) -> 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 "***func*** \`load_from_files(*files: str, *, no_warning: bool = False) -> dict[str, Any]\`""></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;">) -> 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;"> """</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:#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;">'.yaml'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'yml'</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;">'.json'</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;">'.toml'</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;">'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;">'</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;">'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;">'</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) -> 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 "***func*** \`load_configs_from_dirs(*directories: str, *, no_waring: bool = False) -> dict[str, Any]\`""></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;">) -> 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;"> """</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;"> """</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;">'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;">'</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) -> 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 "***func*** \`load_config_in_default(no_waring: bool = False) -> dict[str, Any]\`""></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;">) -> 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;"> """</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;"> """</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;">'config'</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;">'config.yaml'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'config.toml'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'config.json'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'config.yml'</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};
|
1
assets/dev_api_config.md.B6-1F5M4.lean.js
Normal file
1
assets/dev_api_config.md.B6-1F5M4.lean.js
Normal 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};
|
1
assets/dev_api_core_core.md.Cq6tYyxr.js
Normal file
1
assets/dev_api_core_core.md.Cq6tYyxr.js
Normal 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};
|
1
assets/dev_api_core_core.md.Cq6tYyxr.lean.js
Normal file
1
assets/dev_api_core_core.md.Cq6tYyxr.lean.js
Normal 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};
|
1
assets/dev_api_core_index.md.SSSl_XRw.js
Normal file
1
assets/dev_api_core_index.md.SSSl_XRw.js
Normal 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};
|
1
assets/dev_api_core_index.md.SSSl_XRw.lean.js
Normal file
1
assets/dev_api_core_index.md.SSSl_XRw.lean.js
Normal 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};
|
61
assets/dev_api_core_manager.md.CUxE2_uH.js
Normal file
61
assets/dev_api_core_manager.md.CUxE2_uH.js
Normal 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 "liteyuki.core.manager""></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 "***class*** \`ChannelDeliver\`""></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 "***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]])\`""></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 "***class*** \`ProcessManager\`""></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 "***func*** \`__init__(self, lifespan: Lifespan)\`""></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;">'Lifespan'</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 "***func*** \`start_all(self)\`""></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;"> """</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;"> """</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;">'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;">'</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 "***func*** \`add_target(self, name: str, target: TARGET_FUNC, args: tuple = (), kwargs = None)\`""></a></h4><p><strong>说明</strong>: 添加进程</p><p><strong>参数</strong>:</p><blockquote><ul><li>name: 进程名,用于获取和唯一标识</li><li>target: 进程函数</li><li>args: 进程函数参数</li><li>kwargs: 进程函数关键字参数,通常会默认传入chan_active和chan_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;"> """</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;"> """</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;">'</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'</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;">'</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'</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 "***func*** \`join_all(self)\`""></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 "***func*** \`terminate(self, name: str)\`""></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;"> """</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;"> """</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;">'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.'</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;">'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.'</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 "***func*** \`terminate_all(self)\`""></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) -> bool</code> <a class="header-anchor" href="#func-is-process-alive-self-name-str-bool" aria-label="Permalink to "***func*** \`is_process_alive(self, name: str) -> bool\`""></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;">) -> </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;"> """</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;"> """</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;">'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.'</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};
|
1
assets/dev_api_core_manager.md.CUxE2_uH.lean.js
Normal file
1
assets/dev_api_core_manager.md.CUxE2_uH.lean.js
Normal 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};
|
1
assets/dev_api_dev_dev.md.CjVBsWZq.js
Normal file
1
assets/dev_api_dev_dev.md.CjVBsWZq.js
Normal 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};
|
1
assets/dev_api_dev_dev.md.CjVBsWZq.lean.js
Normal file
1
assets/dev_api_dev_dev.md.CjVBsWZq.lean.js
Normal 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};
|
1
assets/dev_api_dev_index.md.Ckrx8rJ6.js
Normal file
1
assets/dev_api_dev_index.md.Ckrx8rJ6.js
Normal 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};
|
1
assets/dev_api_dev_index.md.Ckrx8rJ6.lean.js
Normal file
1
assets/dev_api_dev_index.md.Ckrx8rJ6.lean.js
Normal 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};
|
44
assets/dev_api_dev_observer.md.CK2VQ1dm.js
Normal file
44
assets/dev_api_dev_observer.md.CK2VQ1dm.js
Normal 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 "liteyuki.dev.observer""></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 "var \`CALLBACK_FUNC\`""></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 "var \`FILTER_FUNC\`""></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 "***func*** \`debounce(wait)\`""></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;"> """</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>
|
||||
<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;">></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 "***class*** \`CodeModifiedHandler(FileSystemEventHandler)\`""></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 "***func*** \`on_modified(self, event)\`""></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;">'on_modified must be implemented'</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 "***func*** \`on_created(self, event)\`""></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 "***func*** \`on_deleted(self, event)\`""></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 "***func*** \`on_moved(self, event)\`""></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 "***func*** \`on_any_event(self, event)\`""></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) -> 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 "***func*** \`on_file_system_event(directories: tuple[str], recursive: bool = True, event_filter: FILTER_FUNC = None) -> Callable[[CALLBACK_FUNC], CALLBACK_FUNC]\`""></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;">) -> 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;"> """</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;"> """</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;">) -> </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};
|
1
assets/dev_api_dev_observer.md.CK2VQ1dm.lean.js
Normal file
1
assets/dev_api_dev_observer.md.CK2VQ1dm.lean.js
Normal 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};
|
12
assets/dev_api_dev_plugin.md.CQmBgdvS.js
Normal file
12
assets/dev_api_dev_plugin.md.CQmBgdvS.js
Normal 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 "liteyuki.dev.plugin""></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 "***func*** \`run_plugins(*module_path: str | Path)\`""></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;"> """</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;"> """</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;">'liteyuki.plugins'</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;">'liteyuki.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;"> 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};
|
1
assets/dev_api_dev_plugin.md.CQmBgdvS.lean.js
Normal file
1
assets/dev_api_dev_plugin.md.CQmBgdvS.lean.js
Normal 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};
|
1
assets/dev_api_exception.md.CHNyxSqL.js
Normal file
1
assets/dev_api_exception.md.CHNyxSqL.js
Normal 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};
|
1
assets/dev_api_exception.md.CHNyxSqL.lean.js
Normal file
1
assets/dev_api_exception.md.CHNyxSqL.lean.js
Normal 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};
|
1
assets/dev_api_index.md.D5E434zv.js
Normal file
1
assets/dev_api_index.md.D5E434zv.js
Normal 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 "liteyuki""></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 "var `__version__`""></a></h3><ul><li><p><strong>说明</strong>: 测试版本号</p></li><li><p><strong>默认值</strong>: <code>'6.3.10'</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};
|
1
assets/dev_api_index.md.D5E434zv.lean.js
Normal file
1
assets/dev_api_index.md.D5E434zv.lean.js
Normal 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};
|
18
assets/dev_api_log.md.BTzz4w7t.js
Normal file
18
assets/dev_api_log.md.BTzz4w7t.js
Normal 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 "liteyuki.log""></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) -> str</code> <a class="header-anchor" href="#func-get-format-level-str-str" aria-label="Permalink to "***func*** \`get_format(level: str) -> str\`""></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;">) -> </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;"> 'DEBUG'</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 "***func*** \`init_log(config: dict)\`""></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;"> """</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;"> """</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;">'log_level'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'INFO'</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;">'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:#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;">'DEBUG'</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;">'<blue>'</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;">"</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;">'🐛'</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;"> ''</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"</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;">'INFO'</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;">'<normal>'</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;">"</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;">'ℹ️'</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;"> ''</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"</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;">'SUCCESS'</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;">'<green>'</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;">"</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;">'✅'</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;"> ''</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"</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;">'WARNING'</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;">'<yellow>'</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;">"</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;">'⚠️'</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;"> ''</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"</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;">'ERROR'</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;">'<red>'</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;">"</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;">'⭕'</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;"> ''</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"</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};
|
1
assets/dev_api_log.md.BTzz4w7t.lean.js
Normal file
1
assets/dev_api_log.md.BTzz4w7t.lean.js
Normal 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};
|
36
assets/dev_api_message_event.md.ClMwOOd3.js
Normal file
36
assets/dev_api_message_event.md.ClMwOOd3.js
Normal 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 "liteyuki.message.event""></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 "***class*** \`MessageEvent\`""></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 "***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)\`""></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;">'MessageEvent'</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;"> """</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;"> """</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 "***func*** \`reply(self, message: str | dict[str, Any])\`""></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;"> """</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;"> """</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;">''</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;">'message'</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};
|
1
assets/dev_api_message_event.md.ClMwOOd3.lean.js
Normal file
1
assets/dev_api_message_event.md.ClMwOOd3.lean.js
Normal 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};
|
1
assets/dev_api_message_index.md.CCG9t-zb.js
Normal file
1
assets/dev_api_message_index.md.CCG9t-zb.js
Normal 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};
|
1
assets/dev_api_message_index.md.CCG9t-zb.lean.js
Normal file
1
assets/dev_api_message_index.md.CCG9t-zb.lean.js
Normal 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};
|
35
assets/dev_api_message_matcher.md.C-ROK-bX.js
Normal file
35
assets/dev_api_message_matcher.md.C-ROK-bX.js
Normal 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 "liteyuki.message.matcher""></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 "***class*** \`Matcher\`""></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 "***func*** \`__init__(self, rule: Rule, priority: int, block: bool)\`""></a></h4><p><strong>说明</strong>: 匹配器</p><p><strong>参数</strong>:</p><blockquote><ul><li>rule: 规则</li><li>priority: 优先级 >= 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;"> """</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: 优先级 >= 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;"> """</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) -> Callable[[EventHandler], EventHandler]</code> <a class="header-anchor" href="#func-handle-self-callable-eventhandler-eventhandler" aria-label="Permalink to "***func*** \`handle(self) -> Callable[[EventHandler], EventHandler]\`""></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) -> Callable[[EventHandler], EventHandler]:</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;"> 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;"> """</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) -> 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) -> None</code> <a class="header-anchor" href="#async-func-run-self-event-messageevent-none" aria-label="Permalink to "***async func*** \`run(self, event: MessageEvent) -> None\`""></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) -> </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;"> """</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;"> """</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};
|
1
assets/dev_api_message_matcher.md.C-ROK-bX.lean.js
Normal file
1
assets/dev_api_message_matcher.md.C-ROK-bX.lean.js
Normal 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};
|
1
assets/dev_api_message_message.md.Cd8SbwRa.js
Normal file
1
assets/dev_api_message_message.md.Cd8SbwRa.js
Normal 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};
|
1
assets/dev_api_message_message.md.Cd8SbwRa.lean.js
Normal file
1
assets/dev_api_message_message.md.Cd8SbwRa.lean.js
Normal 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};
|
15
assets/dev_api_message_on.md.BL6JkrM3.js
Normal file
15
assets/dev_api_message_on.md.BL6JkrM3.js
Normal 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 "liteyuki.message.on""></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 "***func*** \`add_matcher(matcher: Matcher)\`""></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;"><</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) -> 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 "***func*** \`on_message(rule: Rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher\`""></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;">) -> 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) -> 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 "***func*** \`on_keywords(keywords: list[str], rule = empty_rule, priority: int = 0, block: bool = False) -> Matcher\`""></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;">) -> 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;">&</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};
|
1
assets/dev_api_message_on.md.BL6JkrM3.lean.js
Normal file
1
assets/dev_api_message_on.md.BL6JkrM3.lean.js
Normal 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};
|
1
assets/dev_api_message_rule.md.Cl4Pbacm.js
Normal file
1
assets/dev_api_message_rule.md.Cl4Pbacm.js
Normal file
File diff suppressed because one or more lines are too long
1
assets/dev_api_message_rule.md.Cl4Pbacm.lean.js
Normal file
1
assets/dev_api_message_rule.md.Cl4Pbacm.lean.js
Normal 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};
|
1
assets/dev_api_message_session.md.CC5IECPx.js
Normal file
1
assets/dev_api_message_session.md.CC5IECPx.js
Normal 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};
|
1
assets/dev_api_message_session.md.CC5IECPx.lean.js
Normal file
1
assets/dev_api_message_session.md.CC5IECPx.lean.js
Normal 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};
|
161
assets/dev_api_mkdoc.md.D83YPFf0.js
Normal file
161
assets/dev_api_mkdoc.md.D83YPFf0.js
Normal file
File diff suppressed because one or more lines are too long
1
assets/dev_api_mkdoc.md.D83YPFf0.lean.js
Normal file
1
assets/dev_api_mkdoc.md.D83YPFf0.lean.js
Normal 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};
|
7
assets/dev_api_plugin_index.md.s_ae6nFU.js
Normal file
7
assets/dev_api_plugin_index.md.s_ae6nFU.js
Normal 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 "liteyuki.plugin""></a></h1><h3 id="func-get-loaded-plugins-dict-str-plugin" tabindex="-1"><em><strong>func</strong></em> <code>get_loaded_plugins() -> dict[str, Plugin]</code> <a class="header-anchor" href="#func-get-loaded-plugins-dict-str-plugin" aria-label="Permalink to "***func*** \`get_loaded_plugins() -> dict[str, Plugin]\`""></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;">() -> 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;"> """</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;"> """</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};
|
1
assets/dev_api_plugin_index.md.s_ae6nFU.lean.js
Normal file
1
assets/dev_api_plugin_index.md.s_ae6nFU.lean.js
Normal 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};
|
83
assets/dev_api_plugin_load.md.Dr9bABNT.js
Normal file
83
assets/dev_api_plugin_load.md.Dr9bABNT.js
Normal 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 "liteyuki.plugin.load""></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) -> Optional[Plugin]</code> <a class="header-anchor" href="#func-load-plugin-module-path-str-path-optional-plugin" aria-label="Permalink to "***func*** \`load_plugin(module_path: str | Path) -> Optional[Plugin]\`""></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) -> Optional[Plugin]:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> """加载单个插件,可以是本地插件或是通过 \`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;"> """</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;">'__plugin_metadata__'</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;">'PluginMetadata'</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;">'__plugin_metadata__'</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;">'.'</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;">'__liteyuki_plugin_meta__'</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;">'PluginMetadata'</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;">'__liteyuki_plugin_meta__'</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;">"</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;">'.'</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;">)"</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;">'__plugin_meta__'</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;">'PluginMetadata'</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;">'__plugin_meta__'</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;">"</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;">'.'</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;">)"</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;">'The metadata of Liteyuki plugin "</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;">" is not specified, use empty.'</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;">'.'</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;">'Succeeded to load liteyuki plugin "</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:#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;">'Failed to load liteyuki plugin "<r></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;"></r>"'</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) -> set[Plugin]</code> <a class="header-anchor" href="#func-load-plugins-plugin-dir-str-ignore-warning-bool-true-set-plugin" aria-label="Permalink to "***func*** \`load_plugins(*plugin_dir: str, *, ignore_warning: bool = True) -> set[Plugin]\`""></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;">) -> set[Plugin]:</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;"> 参数:</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;"> """</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;">"Plugins dir '</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;">' does not exist."</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;">"Plugins dir '</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;">' is empty."</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;">"Plugins dir '</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;">' is not a directory."</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;">'.py'</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;"> '__init__.py'</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;">'</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;">'</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;">'__init__.py'</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) -> str</code> <a class="header-anchor" href="#func-format-display-name-display-name-str-plugin-type-plugintype-str" aria-label="Permalink to "***func*** \`format_display_name(display_name: str, plugin_type: PluginType) -> str\`""></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) -> </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;"> """</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: 设置后的插件名称 <y>name</y></span></span>
|
||||
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> """</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;"> 'y'</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;"> 'm'</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;"> 'g'</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;"> 'e'</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;"> 'c'</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;">'<</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;">></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;">]</</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;">>'</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};
|
1
assets/dev_api_plugin_load.md.Dr9bABNT.lean.js
Normal file
1
assets/dev_api_plugin_load.md.Dr9bABNT.lean.js
Normal 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};
|
1
assets/dev_api_plugin_manager.md.rRp7jB1O.js
Normal file
1
assets/dev_api_plugin_manager.md.rRp7jB1O.js
Normal 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};
|
1
assets/dev_api_plugin_manager.md.rRp7jB1O.lean.js
Normal file
1
assets/dev_api_plugin_manager.md.rRp7jB1O.lean.js
Normal 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};
|
1
assets/dev_api_plugin_model.md.BDcYOOls.js
Normal file
1
assets/dev_api_plugin_model.md.BDcYOOls.js
Normal file
File diff suppressed because one or more lines are too long
1
assets/dev_api_plugin_model.md.BDcYOOls.lean.js
Normal file
1
assets/dev_api_plugin_model.md.BDcYOOls.lean.js
Normal 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};
|
7
assets/dev_api_plugin_plugin.md.0scWi63V.js
Normal file
7
assets/dev_api_plugin_plugin.md.0scWi63V.js
Normal 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 "liteyuki.plugin""></a></h1><h3 id="func-get-loaded-plugins-dict-str-plugin" tabindex="-1"><em><strong>func</strong></em> <code>get_loaded_plugins() -> dict[str, Plugin]</code> <a class="header-anchor" href="#func-get-loaded-plugins-dict-str-plugin" aria-label="Permalink to "***func*** \`get_loaded_plugins() -> dict[str, Plugin]\`""></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;">() -> 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;"> """</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;"> """</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};
|
1
assets/dev_api_plugin_plugin.md.0scWi63V.lean.js
Normal file
1
assets/dev_api_plugin_plugin.md.0scWi63V.lean.js
Normal 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};
|
1
assets/dev_api_plugins_index.md.CSspw-A7.js
Normal file
1
assets/dev_api_plugins_index.md.CSspw-A7.js
Normal 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};
|
1
assets/dev_api_plugins_index.md.CSspw-A7.lean.js
Normal file
1
assets/dev_api_plugins_index.md.CSspw-A7.lean.js
Normal 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};
|
1
assets/dev_api_plugins_liteecho.md.B8fCIJFA.js
Normal file
1
assets/dev_api_plugins_liteecho.md.B8fCIJFA.js
Normal 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 "liteyuki.plugins.liteecho""></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(['liteecho'], 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 "***async func*** `liteecho(event: MessageEvent)`""></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;">'liteecho'</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};
|
1
assets/dev_api_plugins_liteecho.md.B8fCIJFA.lean.js
Normal file
1
assets/dev_api_plugins_liteecho.md.B8fCIJFA.lean.js
Normal 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};
|
@ -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 "liteyuki.plugins.plugin_loader""></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 "***func*** \`default_plugins_loader()\`""></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;"> """</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:#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;">'liteyuki.plugins'</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;">'liteyuki.plugin_dirs'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'src/liteyuki_plugins'</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};
|
@ -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
Loading…
Reference in New Issue
Block a user