51 Commits

Author SHA1 Message Date
c9a4683e98 添加 .domains 2025-03-06 14:42:01 +08:00
317e07eb71 🐛 更新文档页脚信息,添加Liteyukiflare CDN加速说明
Some checks failed
Pre-commit checks / pre-commit (3.10) (push) Failing after 2m43s
Deploy VitePress site to Pages / build (push) Failing after 3m7s
Pre-commit checks / pre-commit (3.13) (push) Failing after 3m10s
Pre-commit checks / pre-commit (3.12) (push) Failing after 13m53s
Pre-commit checks / pre-commit (3.11) (push) Failing after 13m56s
Docker Image Build / build (push) Failing after 14m14s
2025-03-01 03:05:04 +08:00
37749ae15e 📝 使用Liteyukiflare对GitHub Page进行亚太地区加速 2025-03-01 03:04:34 +08:00
f94c10de61 🐛 修正 Docker 镜像标签的大小写,更新相关文档中的镜像拉取命令
Some checks failed
Pre-commit checks / pre-commit (3.10) (push) Failing after 5s
Pre-commit checks / pre-commit (3.12) (push) Failing after 4s
Pre-commit checks / pre-commit (3.11) (push) Failing after 11s
Pre-commit checks / pre-commit (3.13) (push) Failing after 5s
Docker Image Build / build (push) Failing after 1m41s
Deploy VitePress site to Pages / build (push) Failing after 1m46s
2025-02-18 09:08:50 +08:00
5ccef735be 🐛 更新 Docker 镜像拉取地址,修正文档中的镜像源 2025-02-18 09:07:37 +08:00
262002b49a 🐛 更新 GitHub 容器注册表登录配置,修正 Docker 镜像构建和推送步骤 2025-02-18 09:06:52 +08:00
40c6ba6d9e 🐛 更新管道依赖,修复管道句柄错误
Some checks failed
Pre-commit checks / pre-commit (3.10) (push) Failing after 32s
Docker Image Build / build (push) Failing after 55s
Pre-commit checks / pre-commit (3.12) (push) Failing after 39s
Pre-commit checks / pre-commit (3.11) (push) Failing after 3m28s
Pre-commit checks / pre-commit (3.13) (push) Failing after 3m59s
Deploy VitePress site to Pages / build (push) Failing after 10m0s
2025-02-18 06:47:31 +08:00
60093b562b 🐛 移除 Gotify 插件及相关配置,更新依赖项版本 2025-02-18 06:42:42 +08:00
30880ec13b 在 README 中添加 LiteyukiLab 的徽章链接
Some checks failed
Docker Image Build / build (push) Failing after 32s
Deploy VitePress site to Pages / build (push) Failing after 53s
Pre-commit checks / pre-commit (3.10) (push) Failing after 1m36s
Pre-commit checks / pre-commit (3.11) (push) Failing after 1m38s
Pre-commit checks / pre-commit (3.12) (push) Failing after 1m58s
Pre-commit checks / pre-commit (3.13) (push) Failing after 1m47s
2025-01-13 00:57:50 +08:00
cc1d82312a 添加新的图标配置,更新链接以指向新的资源 2025-01-13 00:49:01 +08:00
efca13d397 🐛 移除 requirements.txt 中的 pip 依赖项
Some checks failed
Docker Image Build / build (push) Failing after 18s
Deploy VitePress site to Pages / build (push) Failing after 52s
Pre-commit checks / pre-commit (3.10) (push) Failing after 1m25s
Pre-commit checks / pre-commit (3.11) (push) Failing after 1m7s
Pre-commit checks / pre-commit (3.12) (push) Failing after 1m27s
Pre-commit checks / pre-commit (3.13) (push) Failing after 1m25s
2024-12-14 02:59:55 +08:00
3a8c09d6db 🐛 删除 __pypackages__ 目录的 .gitignore 文件,并更新主 .gitignore 文件以忽略 pdm 相关文件 2024-12-14 02:57:51 +08:00
cc1bb8e5e4 添加 pre-commit 配置和工作流,集成代码格式化和静态检查工具
Some checks failed
Docker Image Build / build (push) Failing after 29s
Deploy VitePress site to Pages / build (push) Failing after 53s
Pre-commit checks / pre-commit (3.10) (push) Failing after 2m17s
Pre-commit checks / pre-commit (3.11) (push) Failing after 2m1s
Pre-commit checks / pre-commit (3.13) (push) Failing after 2m18s
Pre-commit checks / pre-commit (3.12) (push) Failing after 2m57s
2024-12-13 19:35:07 +08:00
93c17b6026 添加新的配置加载器,支持从YAML、TOML、JSON和环境变量加载配置,并修改默认主机地址
Some checks failed
Docker Image Build / build (push) Failing after 1m25s
Deploy VitePress site to Pages / build (push) Failing after 1m50s
2024-12-02 21:46:29 +08:00
fd3f6272f1 🐛 修复获取系统语言代码的逻辑,处理None值的情况
Some checks failed
Docker Image Build / build (push) Failing after 35s
Deploy VitePress site to Pages / build (push) Failing after 2m11s
2024-11-29 00:04:34 +08:00
4d87a3c0b7 Merge branch 'main' of https://git.liteyuki.icu/bot/app 2024-11-29 00:03:14 +08:00
86f47ee411 🐛 修复获取系统语言代码的逻辑,添加对None值的处理 2024-11-29 00:01:49 +08:00
1d6b8d60f3 Merge pull request #89 from Asankilp/main
Some checks failed
Docker Image Build / build (push) Failing after 21s
Deploy VitePress site to Pages / build (push) Failing after 53s
添加uninfo依赖项
2024-11-27 01:47:23 +08:00
3890704045 添加uninfo依赖项 2024-11-27 01:44:49 +08:00
b0761e9873 🐛 更新docker-compose.yml,修改时区设置为Asia/Chongqing
Some checks failed
Docker Image Build / build (push) Failing after 19s
Deploy VitePress site to Pages / build (push) Failing after 55s
2024-11-23 22:31:51 +08:00
291314de93 新增docker-compose.yml文件,定义应用服务及其配置 2024-11-23 22:31:06 +08:00
fd835e9406 更新.gitignore,新增Python工具链缓存目录排除项;更新README.md,调整标题并添加monorepo说明
Some checks failed
Docker Image Build / build (push) Failing after 37s
Deploy VitePress site to Pages / build (push) Failing after 57s
2024-11-22 20:15:04 +08:00
d681c5645a 🐛 更新Dockerfile,新增libpango-1.0-0和libcairo2依赖
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 1m0s
Docker Image Build / build (push) Failing after 1m8s
2024-11-21 19:53:49 +08:00
d0619f1fe8 优化Dockerfile,移除不必要的sources.list复制步骤,简化pip安装命令
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 1m2s
Docker Image Build / build (push) Failing after 1m29s
2024-11-16 02:24:47 +08:00
b022a364e3 更新GitHub Actions工作流,修改并发组名称为“docker-build” 2024-11-16 02:20:06 +08:00
df00c61dd8 新增GitHub Actions工作流以构建和推送Docker镜像,更新.gitignore以排除.github目录 2024-11-16 02:19:31 +08:00
94a021bab0 更新安装文档,替换Docker构建步骤为拉取最新夜间版镜像 2024-11-16 02:17:06 +08:00
6b20e9eae0 更新README.md,将“参考及鸣”更正为“参考及鸣谢”
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 2m9s
2024-11-10 01:20:14 +08:00
0a35a3c6f8 修正README.md中的链接错误,将“lightyuki-link”更正为“liteyuki-link” 2024-11-10 01:19:58 +08:00
2e75c7bc65 更新README.md,新增GitHub和官方仓库链接,优化内容结构
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 1m17s
2024-11-10 01:15:34 +08:00
3341505715 更新LiteyukiBot克隆命令中的镜像链接
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 2m52s
2024-11-09 23:52:17 +08:00
bdde9c45fd 优化配置文件格式和清理无用调试信息,修改gitea仓库路径 2024-11-09 23:51:35 +08:00
7bf94a15c8 📝 文档新增插件通信部分内容
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 1m10s
2024-10-26 02:34:58 +08:00
4510477026 Merge branch 'main' of https://github.com/LiteyukiStudio/LiteyukiBot
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 15s
2024-10-23 01:06:47 +08:00
86e50e369b 初步对Uninfo的支持 2024-10-23 01:04:42 +08:00
796fc6f233 Merge pull request #88 from EillesWan/main
🌠也许,大家的测试环境都是*nix?
2024-10-22 13:36:57 +08:00
80c6875567 🌠也许,大家的测试环境都是*nix?
Update file.py
2024-10-22 13:34:09 +08:00
ab89cd1c72 性能提升200倍
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 11m46s
2024-10-20 23:37:40 +08:00
5e454bc971 性能提升200倍 2024-10-20 23:36:49 +08:00
70bfb0fcee 性能提升200倍 2024-10-20 23:35:44 +08:00
13b95c2732 🐛 修复一些细节小问题 2024-10-20 20:59:30 +08:00
ef5866343d add: nonebot-plugin-gotify 2024-10-20 04:12:17 +08:00
d5ccd105a2 add: nonebot-plugin-gotify 2024-10-20 03:11:26 +08:00
20ad8dc53f 🐛 hotfix: from mypy import 2024-10-19 21:15:37 +08:00
de9c91d8bd 🐛 hotfix: from mypy import 2024-10-19 21:12:55 +08:00
6b64a0c379 🐛 hotfix: from mypy import 2024-10-19 21:10:18 +08:00
f117da7ff3 🎨 更新轻雪依赖版本
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 7m29s
2024-10-14 20:57:30 +08:00
f548a07230 📝 文档删除常规部署,强制使用虚拟环境 2024-10-14 20:51:37 +08:00
e2e53c21fa 📝 文档删除常规部署,强制使用虚拟环境
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 15s
2024-10-14 01:03:06 +08:00
3eaf23a56b 📝 文档删除常规部署,强制使用虚拟环境 2024-10-14 01:02:57 +08:00
4a5dd1f727 🐛 修复一些细节小问题 2024-10-14 00:57:33 +08:00
407 changed files with 1957 additions and 2322 deletions

0
.dockerignore Normal file → Executable file
View File

1
.domains Normal file
View File

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

0
.github/ISSUE_TEMPLATE/config.yml vendored Normal file → Executable file
View File

0
.github/ISSUE_TEMPLATE/resource_publish_en.yml vendored Normal file → Executable file
View File

0
.github/ISSUE_TEMPLATE/resource_publish_zh.yml vendored Normal file → Executable file
View File

0
.github/ISSUE_TEMPLATE/问题反馈.md vendored Normal file → Executable file
View File

0
.github/dependabot.yml vendored Normal file → Executable file
View File

43
.github/workflows/build-image.yml vendored Executable file
View File

@ -0,0 +1,43 @@
name: Docker Image Build
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write
concurrency:
group: docker-build
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/liteyukistudio/liteyukibot:latest
- name: Log out from GitHub Container Registry
run: docker logout ghcr.io

0
.github/workflows/deploy-docs.yml vendored Normal file → Executable file
View File

0
.github/workflows/issue_handler.yml vendored Normal file → Executable file
View File

30
.github/workflows/pre-commit.yml vendored Executable file
View File

@ -0,0 +1,30 @@
name: Pre-commit checks
on: [push, pull_request]
jobs:
pre-commit:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13'] # 添加你想要测试的 Python 版本
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }} # 使用矩阵中的 Python 版本
- name: Install dependencies
run: |
python -m pip install pdm
python -m pip install pre-commit
pdm config python.use_venv false
pdm install --no-lock
pre-commit install
- name: Run pre-commit
run: pre-commit run --all-files

0
.github/workflows/pypi-publish.yml vendored Normal file → Executable file
View File

11
.gitignore vendored Normal file → Executable file
View File

@ -24,7 +24,6 @@ config.yml
config.example.yml
# vuepress
.github
# mupy
mypy.ini
@ -64,4 +63,12 @@ mkdoc.bat
# vitepress
docs/.vitepress/dist/
docs/.vitepress/cache
docs/.vitepress/.temp
docs/.vitepress/.temp
# python toolchain
.mypy_cache/
.pytest_cache/
# pdm
__pypackages__/
pdm.lock

26
.pre-commit-config.yaml Executable file
View File

@ -0,0 +1,26 @@
fail_fast: true
repos:
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: [--config=./pyproject.toml]
- repo: https://github.com/timothycrosley/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

6
Dockerfile Normal file → Executable file
View File

@ -2,17 +2,15 @@ FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/python:3.10-slim
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 pip install --no-cache-dir -r requirements.txt
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
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 libpango-1.0-0 libcairo2
EXPOSE 20216

0
LICENSE Normal file → Executable file
View File

50
README.md Normal file → Executable file
View File

@ -1,15 +1,24 @@
<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]
[![][banner]][liteyuki-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]
[![][Liteyuki6.0]][liteyuki-link]
[![][Python3.10+]][python-link]
[![][Usage]][usage-link]
[![][Repo]][repo-link]
[![][Github]][github-link]
[![][LiteyukiLab]][liteyukilab-link]
</div>
## 关于
访问[轻雪6.0](https://bot.liteyuki.icu)主页获取更多信息
## 特点及优势
- 原生支持与任意`Python`Bot框架互联有良好的生态支持
- 开箱即用,无需复杂配置
@ -18,32 +27,43 @@
- 国际化支持,支持多种语言
- 高性能500插件2s内启动
<h3>👇更多内容请访问👇</h3>
<h2><a href="https://bot.liteyuki.icu">轻雪机器人主页</a></h2>
</div>
## 服务及支持(敬请期待)
- 提供Liteyuki Cloud官方的容器化托管服务无需担心服务器问题
### 感谢
- 所有贡献者们
**👇所有内容请访问👇**: [bot.liteyuki.icu](https://bot.liteyuki.icu)
## 参考及鸣谢
- [nonebot-plugin-uninfo](https://github.com/RF-Tar-Railt/nonebot-plugin-uninfo)为会话部分用户信息提供了参考
- [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna/)为消息部分提供了参考
[OneBot]: https://img.shields.io/badge/OneBot-11/12-blue?style=for-the-badge
## 其他
- 本仓库是一个monorepo包含了框架文档测试内置资源包内置插件预设配置等
[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
[Usage]: https://img.shields.io/badge/主页-文档-blue?style=for-the-badge
[onebot-link]:https://onebot.dev/
[Repo]: https://img.shields.io/badge/官方托管-仓库-blue?style=for-the-badge
[Github]: https://img.shields.io/badge/Github-仓库-blue?style=for-the-badge
[LiteyukiLab]: https://img.shields.io/badge/轻雪社区-官方-blue?style=for-the-badge
[nonebot-link]:https://nonebot.dev/
[lightyuki-link]:/
[python-link]:https://www.python.org/
[usage-link]:https://bot.liteyuki.icu/
[liteyuki-link]:https://bot.liteyuki.icu/
[repo-link]:https://git.liteyuki.icu/bot/app
[github-link]:https://github.com/LiteyukiStudio/LiteyukiBot
[liteyukilab-link]:https://lab.liteyuki.icu/@LiteyukiBot
[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

6
config/default.yml Normal file → Executable file
View File

@ -1,8 +1,10 @@
nonebot:
host: 127.0.0.1
host: 0.0.0.0
port: 20216
command_start: ["", "/"]
nickname: [ "liteyuki" ]
default_language: zh
driver: ~fastapi+~httpx+~websockets
alconna_use_command_start: true
alconna_use_command_start: true
gotify_token: "empty token"

12
docker-compose.yml Executable file
View File

@ -0,0 +1,12 @@
version: '3.8'
services:
app:
image: git.liteyuki.icu/bot/app:latest
ports:
- "20216:20216"
environment:
- TZ=Asia/Chongqing
volumes:
- .:/liteyukibot
command: [ "python", "main.py" ]

0
docker/sources.list Normal file → Executable file
View File

27
docs/.vitepress/config/common.ts Normal file → Executable file
View File

@ -1,9 +1,9 @@
// 共有配置项导入index用
import {defineConfig} from 'vitepress'
import {generateSidebar} from 'vitepress-sidebar';
import {zh} from "./zh";
import {en} from "./en";
import { defineConfig } from 'vitepress'
import { generateSidebar } from 'vitepress-sidebar';
import { zh } from "./zh";
import { en } from "./en";
let defaultLocale = 'zh';
const commonSidebarOptions = {
@ -48,13 +48,12 @@ function generateSidebarConfig(): any[] {
return ret
}
console.log(generateSidebarConfig())
export const common = defineConfig({
head: [
// 配置favicon.ico
['link', {rel: 'icon', type: 'image/x-icon', href: 'favicon.ico'}],
['link', {rel: 'stylesheet', href: 'https://fonts.font.im/css?family=Cousine:400,400i,700,700i|Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i'}],
['link', { rel: 'icon', type: 'image/x-icon', href: 'favicon.ico' }],
['link', { rel: 'stylesheet', href: 'https://fonts.font.im/css?family=Cousine:400,400i,700,700i|Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i' }],
],
rewrites: {
[`${defaultLocale}/:rest*`]: ":rest*",
@ -71,12 +70,18 @@ export const common = defineConfig({
]
),
socialLinks: [
{icon: 'github', link: 'https://github.com/LiteyukiStudio/LiteyukiBot'},
{ icon: 'github', link: 'https://github.com/LiteyukiStudio/LiteyukiBot' },
{
icon: {
svg: '<svg t="1725391346807" class="icon" viewBox="0 0 1025 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5067" width="256" height="256"><path d="M1004.692673 466.396616l-447.094409-447.073929c-25.743103-25.763582-67.501405-25.763582-93.264987 0l-103.873521 103.873521 78.171378 78.171378c12.533635-6.00058 26.562294-9.359266 41.389666-9.359266 53.02219 0 96.00928 42.98709 96.00928 96.00928 0 14.827372-3.358686 28.856031-9.359266 41.389666l127.97824 127.97824c12.533635-6.00058 26.562294-9.359266 41.389666-9.359266 53.02219 0 96.00928 42.98709 96.00928 96.00928s-42.98709 96.00928-96.00928 96.00928-96.00928-42.98709-96.00928-96.00928c0-14.827372 3.358686-28.856031 9.359266-41.389666l-127.97824-127.97824c-3.051489 1.454065-6.184898 2.744293-9.379746 3.870681l0 266.97461c37.273227 13.188988 63.99936 48.721433 63.99936 90.520695 0 53.02219-42.98709 96.00928-96.00928 96.00928s-96.00928-42.98709-96.00928-96.00928c0-41.799262 26.726133-77.331707 63.99936-90.520695l0-266.97461c-37.273227-13.188988-63.99936-48.721433-63.99936-90.520695 0-14.827372 3.358686-28.856031 9.359266-41.389666l-78.171378-78.171378-295.892081 295.871601c-25.743103 25.784062-25.743103 67.542365 0 93.285467l447.114889 447.073929c25.743103 25.743103 67.480925 25.743103 93.264987 0l445.00547-445.00547c25.763582-25.763582 25.763582-67.542365 0-93.285467z" fill="#a2d8f4" p-id="5068"></path></svg>'
},
link: "https://git.liteyuki.icu/LiteyukiStudio/LiteyukiBot"
link: "https://git.liteyuki.icu/bot/app"
},
{
icon:{
svg:'<svg t="1736700504329" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="14158" width="200" height="200"><path d="M944.355556 142.222222c-17.066667-22.755556-45.511111-34.133333-79.644445-34.133333-28.444444 0-68.266667 5.688889-108.088889 22.755555h-5.688889c17.066667 11.377778 34.133333 28.444444 51.2 39.822223 56.888889-17.066667 91.022222-11.377778 96.711111 0 11.377778 11.377778 5.688889 45.511111-22.755555 91.022222 11.377778 17.066667 17.066667 34.133333 28.444444 51.2 0 0 0 5.688889 5.688889 5.688889 22.755556-34.133333 34.133333-62.577778 45.511111-91.022222 11.377778-28.444444 5.688889-62.577778-11.377777-85.333334z" p-id="14159" fill="#a2d8f4"></path><path d="M267.377778 512a45.511111 45.511111 0 1 0 91.022222 0 45.511111 45.511111 0 1 0-91.022222 0Z" p-id="14160" fill="#a2d8f4"></path><path d="M625.777778 614.4c-113.777778 85.333333-227.555556 153.6-324.266667 193.422222-11.377778 5.688889-17.066667 5.688889-28.444444 11.377778 22.755556 17.066667 51.2 34.133333 79.644444 45.511111 51.2 22.755556 108.088889 34.133333 164.977778 34.133333s113.777778-11.377778 164.977778-34.133333c51.2-22.755556 96.711111-51.2 136.533333-91.022222 39.822222-39.822222 68.266667-85.333333 91.022222-130.844445 22.755556-51.2 34.133333-108.088889 34.133334-159.288888 0-51.2-11.377778-102.4-28.444445-153.6-5.688889 5.688889-11.377778 17.066667-17.066667 22.755555-68.266667 79.644444-164.977778 176.355556-273.066666 261.688889zM813.511111 187.733333c-5.688889-5.688889-11.377778-5.688889-11.377778-11.377777-17.066667-17.066667-34.133333-28.444444-51.2-39.822223-22.755556-11.377778-45.511111-28.444444-68.266666-34.133333-56.888889-28.444444-108.088889-39.822222-164.977778-39.822222s-113.777778 11.377778-164.977778 34.133333c-51.2 22.755556-96.711111 51.2-136.533333 91.022222-39.822222 34.133333-68.266667 79.644444-91.022222 130.844445-22.755556 51.2-34.133333 108.088889-34.133334 159.288889 0 51.2 11.377778 96.711111 22.755556 142.222222-22.755556 34.133333-39.822222 68.266667-51.2 96.711111-11.377778 39.822222-5.688889 68.266667 11.377778 91.022222 17.066667 22.755556 45.511111 34.133333 79.644444 34.133334h11.377778c28.444444 0 62.577778-11.377778 96.711111-22.755556-17.066667-11.377778-34.133333-28.444444-51.2-39.822222-51.2 11.377778-85.333333 11.377778-96.711111 0 0-17.066667 5.688889-45.511111 34.133333-96.711111 17.066667 34.133333 39.822222 62.577778 68.266667 91.022222h5.688889c17.066667-5.688889 39.822222-11.377778 62.577777-17.066667 91.022222-34.133333 204.8-102.4 307.2-187.733333 108.088889-85.333333 199.111111-170.666667 256-250.311111l34.133334-51.2c-22.755556-28.444444-39.822222-56.888889-68.266667-79.644445z m-500.622222 420.977778c-56.888889 0-102.4-45.511111-102.4-102.4s45.511111-102.4 102.4-102.4S409.6 455.111111 409.6 512c0 51.2-45.511111 96.711111-96.711111 96.711111z" p-id="14161" fill="#a2d8f4"></path></svg>'
},
link: 'https://lab.liteyuki.icu/@LiteyukiBot'
}
],
search: {
@ -124,8 +129,8 @@ export const common = defineConfig({
},
lastUpdated: true,
locales: {
root: {label: "简体中文", ...zh},
en: {label: "English", ...en},
root: { label: "简体中文", ...zh },
en: { label: "English", ...en },
},
})

2
docs/.vitepress/config/en.ts Normal file → Executable file
View File

@ -20,7 +20,7 @@ export const en = defineConfig({
'Edit this page on GitHub',
),
footer: {
message: 'Documentation built with <a href="https://vitepress.dev/">VitePress</a> | API references generated by <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a>',
message: 'Page accelerated by <a href="https://cdn.liteyuki.icu" target="_blank">Liteyukiflare CDN</a><br>Documentation built with <a href="https://vitepress.dev/">VitePress</a> | API references generated by <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a>',
copyright: ThemeConfig.copyright
},
outline: ThemeConfig.getOutLine("Page Content"),

0
docs/.vitepress/config/index.ts Normal file → Executable file
View File

0
docs/.vitepress/config/utils.ts Normal file → Executable file
View File

2
docs/.vitepress/config/zh.ts Normal file → Executable file
View File

@ -20,7 +20,7 @@ export const zh = defineConfig({
'在 GitHub 上编辑此页',
),
footer: {
message: '文档由 <a href="https://vitepress.dev/">VitePress</a> 构建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成',
message: '页面由 <a href="https://cdn.liteyuki.icu" target="_blank">Liteyukiflare CDN</a> 提供加速服务<br>文档由 <a href="https://vitepress.dev/">VitePress</a> 构建 | API引用由 <a href="https://github.com/LiteyukiStudio/litedoc">litedoc</a> 生成',
copyright: ThemeConfig.copyright
},
outline: ThemeConfig.getOutLine("页面内容"),

0
docs/.vitepress/theme/index.ts Normal file → Executable file
View File

0
docs/.vitepress/theme/liteyuki.scss Normal file → Executable file
View File

0
docs/components/ContributorBar.vue Normal file → Executable file
View File

0
docs/components/Dash.vue Normal file → Executable file
View File

0
docs/components/Geo.vue Normal file → Executable file
View File

0
docs/components/Home.vue Normal file → Executable file
View File

0
docs/components/PluginItemCard.vue Normal file → Executable file
View File

0
docs/components/PluginStore.vue Normal file → Executable file
View File

0
docs/components/ResItemCard.vue Normal file → Executable file
View File

0
docs/components/ResPubWindow.vue Normal file → Executable file
View File

0
docs/components/ResStore.vue Normal file → Executable file
View File

0
docs/components/StatsBar.vue Normal file → Executable file
View File

0
docs/components/Tabs.vue Normal file → Executable file
View File

0
docs/components/ToggleSwitch.vue Normal file → Executable file
View File

0
docs/components/TryLiteyukiWindow.vue Normal file → Executable file
View File

0
docs/components/scripts/const.ts Normal file → Executable file
View File

0
docs/components/scripts/i18n.ts Normal file → Executable file
View File

0
docs/components/scripts/statsApi.ts Normal file → Executable file
View File

0
docs/en/deploy/config.md Normal file → Executable file
View File

34
docs/en/deploy/fandq.md Normal file → Executable file
View File

@ -10,20 +10,11 @@ order: 3
- You can specify which python interpreter to use by using the full path to the python executable, for example, `/path/to/python main.py`
- Use virtual environments to avoid conflicts between different python interpreters
- Why does the bot not respond after I start it?
- Please check the configuration file `command_start` or `superusers`, make sure you have permission to use the command and send it correctly
- Make sure the command header does not conflict with `nickname{}`, for example, a command is `help`, but the `Bot` nickname has a `help`, then it will be parsed as a nickname instead of a command
- Update Liteyuki failed, error `InvalidGitRepositoryError`
- Please install `Git` correctly and deploy Liteyuki using cloning instead of direct download
- How to log in to chat platforms such as Telegram?
- If you have this question, it means you don't know much about this project.
This project does not implement the login function, only the message processing and response.
The login function is provided by the implementation side (protocol side). The implementation side itself does not handle response logic.
It processes and reports messages to Liteyuki according to the OneBot standard.
You need to use an implementation side that complies with the OneBot standard to connect to Liteyuki and report messages to Liteyuki.
Some recommended implementation sides have been listed below
- How to log in to chat platforms?
- Some plugins provide the ability to log in to specific platforms, for example, using the NoneBot plugin to log in to supported adapter platforms
- `Playwright` installation failed
- Enter `playwright install` to install the browser
@ -37,24 +28,3 @@ order: 3
- Join chat group[775840726](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=SzmDYbfR6jY94o9KFNon7AwelRyI6M_u&authKey=ygeBdEmdFNyCWuNR4w0M1M8%2B5oDg7k%2FDfN0tzBkYcnbB%2FGHNnlVEnCIGbdftsnn7&noverify=0&group_code=775840726)
- If you don't have a QQ account, you can [submit an issue on GitHub](https://github.com/LiteyukiStudio/LiteyukiBot/issues/new?assignees=&labels=&projects=&template=%E9%97%AE%E9%A2%98%E5%8F%8D%E9%A6%88.md&title=)
## **Recommended Solution(QQ)**
1. [Lagrange.OneBot](https://github.com/KonataDev/Lagrange.Core), based on `Lagrange.Core`, a Linux QQ implementation, supports OneBotv11 protocol
2. [LLOneBot](https://github.com/LLOneBot/LLOneBot), a plugin for `Liteloader NTQQ`, supports OneBotv11 protocol
3. [OpenShamrock](https://github.com/whitechi73/OpenShamrock), based on Lsposed, supports kritor protocol
4. [TRSS-Yunzai](https://github.com/TimeRainStarSky/Yunzai), based on `Node.js`, supports OneBotv11 protocol
5. [go-cqhttp](https://github.com/Mrs4s/go-cqhttp)A QQ Client based on `go`, supports OneBotv11 protocol
6. [Gensokyo](https://github.com/Hoshinonyaruko/Gensokyo), use QQ protocol
## **Recommended Solution(Minecraft)**
1. [MinecraftOneBot](https://github.com/snowykami/MinecraftOnebot), We develop a Minecraft server chat bot
Other project encountered issues, please prioritize the documentation and issues of the project itself, don't ask LiteyukiBot developers
## **Acknowledgements**
- [Nonebot2](https://nonebot.dev) provides the underlying framework
- [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna) provides the command parser
- [MiSans](https://hyperos.mi.com/font/zh/)[MapleMono](https://gitee.com/mirrors/Maple-Mono) provides the font

29
docs/en/deploy/install.md Normal file → Executable file
View File

@ -9,13 +9,23 @@ order: 1
1. Install [`Git`](https://git-scm.com/download/) and [`Python3.10+`](https://www.python.org/downloads/release/python-31010/) Environment.
```bash
# Clone the project
# Clone Repo
git clone https://github.com/LiteyukiStudio/LiteyukiBot --depth=1
# change directory
# Change directory
cd LiteyukiBot
# install dependencies
# Create virtual environment
python -m venv venv
# Activate virtual environment
.\venv\Scripts\activate # Windows
source venv/bin/activate # Linux
# Install dependencies
pip install -r requirements.txt
# start the bot!
# Run Liteyuki
python main.py
```
@ -27,19 +37,14 @@ python main.py
## **Run with Docker**
1. Install [`Docker`](https://docs.docker.com/get-docker/)
2. Clone Repo `git clone https://github.com/LiteyukiStudio/LiteyukiBot --depth=1`
3. Change directory `cd LiteyukiBot`
4. Build docker image `docker build -t liteyukibot .`
5. Run container `docker run -p 20216:20216 -v $(pwd):/liteyukibot -v $(pwd)/.cache:/root/.cache liteyukibot`
```bash
docker pull ghcr.io/liteyukistudio/liteyukibot:latest # Nightly build
```
> [!tip]
> If you are using Windows, please use the absolute project directory `/path/to/LiteyukiBot` instead of `$&#40;pwd&#41;` <br>
> If you have modified the port number, please replace `20216:20216` with your port number
## **Use TRSS Script**
[TRSS_Liteyuki Management Script](https://timerainstarsky.github.io/TRSS_Liteyuki/), which provides a more convenient way to manage LiteyukiBot, recommended to use `Arch Linux`
## **Device Requirements**
- Windows system version minimum `Windows10+`/`Windows Server 2019+`

0
docs/en/dev/best_practices.md Normal file → Executable file
View File

0
docs/en/dev/comm.md Normal file → Executable file
View File

0
docs/en/dev/guide.md Normal file → Executable file
View File

0
docs/en/dev/lyfunc.md Normal file → Executable file
View File

4
docs/en/dev/plugin.md Normal file → Executable file
View File

@ -1,11 +1,11 @@
---
title: Liteyuki Plugin
title: Plugin
order: 3
---
# 简介
轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能
轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能
## 开始

0
docs/en/dev/resource.md Normal file → Executable file
View File

0
docs/en/index.md Normal file → Executable file
View File

0
docs/en/store/plugin.md Normal file → Executable file
View File

0
docs/en/store/resource.md Normal file → Executable file
View File

0
docs/en/usage/agreement.md Normal file → Executable file
View File

0
docs/en/usage/basic.md Normal file → Executable file
View File

0
docs/en/usage/extra.md Normal file → Executable file
View File

0
docs/package.json Normal file → Executable file
View File

2248
docs/pnpm-lock.yaml generated Normal file → Executable file

File diff suppressed because it is too large Load Diff

0
docs/public/favicon.ico Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

0
docs/public/liteyuki-dark.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
docs/public/liteyuki.svg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

0
docs/public/plugins.json Normal file → Executable file
View File

0
docs/public/resources.json Normal file → Executable file
View File

0
docs/tsconfig.json Normal file → Executable file
View File

2
docs/zh/deploy/config.md Normal file → Executable file
View File

@ -14,7 +14,7 @@ order: 2
```yaml
nonebot:
# Nonebot机器人的配置以前的最外层配置项仍可为Nonebot服务,但是部分内容会被覆盖,请尽快迁移
# Nonebot机器人的配置6.3.10版本后NoneBot下配置已迁移至nonebot键下不再使用外层配置,但是部分内容会被覆盖,请尽快迁移
command_start: [ "/", "" ] # 指令前缀,若没有""空命令头请开启alconna_use_command_start保证alconna解析正常
host: 127.0.0.1 # 监听地址默认为本机若要接收外部请求请填写0.0.0.0
port: 20216 # 绑定端口

35
docs/zh/deploy/fandq.md Normal file → Executable file
View File

@ -10,43 +10,16 @@ order: 3
然后用`/path/to/python main.py`来启动Bot
其中`/path/to/python`是你要用来运行Bot的可执行文件
- 为什么我启动后机器人没有反应?
- 请检查配置文件的`command_start``superusers`,确认你有权限使用命令并按照正确的命令发送
- 确认命令头没有和`nickname{}`冲突,例如一个命令是`help`,但是`Bot`昵称有一个`help`那么将会被解析为nickname而不是命令
- 更新轻雪失败,报错`InvalidGitRepositoryError`
- 请正确安装`Git`,并使用克隆而非直接下载的方式部署轻雪
- 怎么登录聊天平台例如QQ
- 你有这个问题说明你不是很了解这个项目,本项目不负责实现登录功能,只负责处理和回应消息,登录功能由实现端(协议端)提供,
实现端本身不负责处理响应逻辑将消息按照OneBot标准处理好上报给轻雪
你需要使用Onebot标准的实现端来连接到轻雪并将消息上报给轻雪下面已经列出一些推荐的实现端
- 怎么对接聊天平台?
- Bot部分插件提供了对接特定平台的能力例如使用NoneBot插件可对接支持的适配器平台
- `Playwright`安装失败
- 输入`playwright install`安装浏览器
- 有的插件安装后报错无法启动
- 请先查阅插件文档,确认插件必要配置项完好后,仍然出现问题,请联系插件作者或在安全模式`safe_mode: true`下启动轻雪,在安全模式下你可以使用`npm uninstall`卸载问题插件
- 其他问题
## 其他问题
-
加入QQ群[775840726](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=SzmDYbfR6jY94o9KFNon7AwelRyI6M_u&authKey=ygeBdEmdFNyCWuNR4w0M1M8%2B5oDg7k%2FDfN0tzBkYcnbB%2FGHNnlVEnCIGbdftsnn7&noverify=0&group_code=775840726)
## **推荐方案(QQ)**
1. [Lagrange.OneBot](https://github.com/KonataDev/Lagrange.Core)基于NTQQ的OneBot实现目前Markdown消息支持Lagrange
2. [LLOneBot](https://github.com/LLOneBot/LLOneBot)NTQQ的OneBot插件需要安装NTQQ
3. [OpenShamrock](https://github.com/whitechi73/OpenShamrock)基于Lsposed的OneBot11实现
4. [TRSS-Yunzai](https://github.com/TimeRainStarSky/Yunzai),基于`node.js`,可使用`ws-plugin`进行通信
5. [go-cqhttp](https://github.com/Mrs4s/go-cqhttp)`go`语言实现的OneBot11实现端目前可用性较低
6. [Gensokyo](https://github.com/Hoshinonyaruko/Gensokyo),基于 OneBot QQ官方机器人Api Golang 原生实现,需要官方机器人权限
7. 人工实现的`Onebot`协议自己整一个WebSocket客户端看着QQ的消息然后给轻雪传输数据
## **推荐方案(Minecraft)**
1. [MinecraftOneBot](https://github.com/snowykami/MinecraftOnebot)我们专门为Minecraft开发的服务器Bot支持OneBotV11标准
使用其他项目连接请先自行查阅文档若有困难请联系对应开发者而不是Liteyuki的开发者
## **鸣谢**
- [Nonebot2](https://nonebot.dev)提供的框架支持
- [nonebot-plugin-alconna](https://github.com/ArcletProject/nonebot-plugin-alconna)提供的命令解析功能
- [MiSans](https://hyperos.mi.com/font/zh/)[MapleMono](https://gitee.com/mirrors/Maple-Mono)提供的字体,且遵守了相关字体开源协议

33
docs/zh/deploy/install.md Normal file → Executable file
View File

@ -2,43 +2,45 @@
title: 安装
order: 1
---
# 安装
## **常规部署**
1. 安装 [`Git`](https://git-scm.com/download/) 和 [`Python3.10+`](https://www.python.org/downloads/release/python-31010/) 环境
1. 安装 [`Git`](https://git-scm.com/download/) 和 [
`Python3.10+`](https://www.python.org/downloads/release/python-31010/) 环境
```bash
# 克隆项目到本地轻雪使用Git进行版本管理该步骤为必要项
git clone https://github.com/LiteyukiStudio/LiteyukiBot --depth=1 # 若你不能访问Github可以使用Liteyuki镜像https://git.liteyuki.icu/LiteyukiStudio/LiteyukiBot
git clone https://github.com/LiteyukiStudio/LiteyukiBot --depth=1 # 若你不能访问Github可以使用Liteyuki镜像https://git.liteyuki.icu/bot/app
# 切换到Bot目录下
cd LiteyukiBot
# 创建虚拟环境
python -m venv venv
# 激活虚拟环境
.\venv\Scripts\activate # Windows
source venv/bin/activate # Linux
# 安装依赖
pip install -r requirements.txt
# 启动Bot
python main.py
```
> [!tip]
> 推荐使用虚拟环境来运行轻雪,以避免依赖冲突,你可以使用`python -m venv .venv`来创建虚拟环境,然后使用`.venv\Scripts\activate`来激活虚拟环境Linux下使用`source .venv/bin/activate`激活)
## **使用Docker构建**
1. 安装 [`Docker`](https://docs.docker.com/get-docker/)
2. 克隆项目 `git clone https://github.com/LiteyukiStudio/LiteyukiBot --depth=1`
3. 进入轻雪目录 `cd LiteyukiBot`
4. 构建镜像 `docker build -t liteyukibot .`
5. 启动容器 `docker run -p 20216:20216 -v $(pwd):/liteyukibot -v $(pwd)/.cache:/root/.cache liteyukibot`
```bash
docker pull ghcr.io/liteyukistudio/liteyukibot:latest # 每夜版镜像
```
> [!tip]
> Windows请使用项目绝对目录`/path/to/LiteyukiBot`代替`$(pwd)` <br>
> 若你修改了端口号请将`20216:20216`中的`20216`替换为你的端口号
## **使用TRSS Scripts部署**
[TRSS_Liteyuki轻雪机器人管理脚本](https://timerainstarsky.github.io/TRSS_Liteyuki/)该功能由TRSS提供支持不是LiteyukiBot官方提供的功能推荐使用`Arch Linux`
## **装置要求**
- Windows系统版本最低`Windows10+`/`Windows Server 2019+`
@ -48,7 +50,8 @@ python main.py
- 硬盘: 至少`1GB`空间
> [!warning]
> 如果装置上有多个环境,请使用`path/to/python -m pip install -r requirements.txt`来安装依赖,`path/to/python`为你的Python可执行文件路径
> 如果装置上有多个环境,请使用`path/to/python -m pip install -r requirements.txt`来安装依赖,`path/to/python`
> 为你的Python可执行文件路径
> [!warning]
> 轻雪的更新功能依赖Git如果你没有安装Git直接下载源代码运行你将无法使用更新功能

0
docs/zh/dev/best_practices.md Normal file → Executable file
View File

4
docs/zh/dev/comm.md Normal file → Executable file
View File

@ -7,9 +7,7 @@ order: 4
### 简介
轻雪运行在主进程 MainProcess 里,其他插件框架进程是伴随的子进程,因此无法通过内存共享和直接对象传递的方式进行通信
轻雪提供了一个通道[`Channel`](./api/comm/channel#class-channel-generic-t)用于跨进程通信,
你可以通过[`Channel`](./api/comm/channel#class-channel-generic-t)发送消息给其他进程,也可以监听其他进程的消息。
轻雪运行在主进程 MainProcess 里,有部分实现插件为了一些功能在子进程中运行,这样两个进程上下文是不会互相干扰的,因此无法通过共享内存和直接对象传递进行通信
例如子进程接收到用户信息需要重启机器人,这时可以通过通道对主进程发送消息,主进程接收到消息后重启对应子进程。

0
docs/zh/dev/guide.md Normal file → Executable file
View File

0
docs/zh/dev/lyfunc.md Normal file → Executable file
View File

12
docs/zh/dev/plugin.md Normal file → Executable file
View File

@ -1,5 +1,5 @@
---
title: 轻雪插件开发
title: 插件开发
order: 3
---
@ -7,6 +7,16 @@ order: 3
轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能
插件大致可分为应用(Application)、实现(Implementation)及服务(Service)等几种类型,大部分情况下一个插件通常承担着多个责任,可按需调整
应用:从总线通道接收到消息后进行处理,响应,以实现某些功能,例如`echo`
实现:对接特定平台,把平台的消息转换为轻雪消息格式传入总线通道
服务提供一系列对外的ipc/rpc/http等服务供其他插件调用
我们鼓励使用`magicoca`进行对象传递来进行插件间通信而不是依赖关系,这样可以避免很多潜在的问题。
## 开始
### 创建插件

0
docs/zh/dev/resource.md Normal file → Executable file
View File

0
docs/zh/index.md Normal file → Executable file
View File

0
docs/zh/store/plugin.md Normal file → Executable file
View File

0
docs/zh/store/resource.md Normal file → Executable file
View File

0
docs/zh/usage/agreement.md Normal file → Executable file
View File

0
docs/zh/usage/basic.md Normal file → Executable file
View File

0
docs/zh/usage/extra.md Normal file → Executable file
View File

0
liteyuki/EN.LICENSE Normal file → Executable file
View File

0
liteyuki/LICENSE Normal file → Executable file
View File

0
liteyuki/__init__.py Normal file → Executable file
View File

32
liteyuki/bot/__init__.py Normal file → Executable file
View File

@ -1,22 +1,22 @@
import asyncio
import atexit
import os
import platform
import signal
import sys
import threading
import time
from typing import Any, Optional
from magicoca import Chan
from liteyuki.bot.lifespan import LIFESPAN_FUNC, Lifespan, PROCESS_LIFESPAN_FUNC
from liteyuki.comm.channel import get_channel
from liteyuki.core.manager import ProcessManager
from liteyuki.log import init_log, logger
from liteyuki.plugin import load_plugin
from liteyuki.utils import IS_MAIN_PROCESS
# new version
from liteyuki.core.manager import sub_process_manager
from liteyuki.log import init_log, logger
from liteyuki.plugin import load_plugin
from liteyuki.session import message_handler_thread
from liteyuki.utils import IS_MAIN_PROCESS
__all__ = [
"LiteyukiBot",
@ -33,6 +33,10 @@ class LiteyukiBot:
Args:
**kwargs: 配置
"""
"""总通道"""
self.i_chan = Chan[Any]() # 外部输入通道
self.o_chan = Chan[Any]() # 外部输出通道
"""常规操作"""
print_logo()
global _BOT_INSTANCE
@ -65,7 +69,7 @@ class LiteyukiBot:
await self.lifespan.before_start() # 启动前钩子
sub_process_manager.start_all()
await self.lifespan.after_start() # 启动后钩子
await self.keep_alive()
message_handler_thread([_.ctx.sub_chan for _ in sub_process_manager.processes.values()])
def run(self):
"""
@ -77,19 +81,7 @@ class LiteyukiBot:
except KeyboardInterrupt:
logger.opt(colors=True).info("<y>Liteyuki is stopping...</y>")
self.stop()
logger.opt(colors=True).info("<y>Liteyuki is stopped...</y>")
async def keep_alive(self):
"""
保持轻雪运行
"""
logger.info("Liteyuki is keeping alive...")
try:
while not self.stop_event.is_set():
await asyncio.sleep(0.1)
except Exception:
logger.info("Liteyuki is exiting...")
self.stop()
logger.opt(colors=True).info("<y>Liteyuki is stopped !</y>")
def restart(self, delay: int = 0):
"""

0
liteyuki/bot/lifespan.py Normal file → Executable file
View File

0
liteyuki/comm/__init__.py Normal file → Executable file
View File

5
liteyuki/comm/channel.py Normal file → Executable file
View File

@ -75,11 +75,6 @@ class Channel(Generic[T]):
if name in _channel:
raise ValueError(f"Channel {name} already exists")
_channel[name] = self
logger.debug(f"Channel {name} initialized in main process")
else:
logger.debug(
f"Channel {name} initialized in sub process, should manually set in main process"
)
def _get_generic_type(self) -> Optional[type]:
"""

0
liteyuki/comm/event.py Normal file → Executable file
View File

View File

@ -1,48 +0,0 @@
# -*- coding: utf-8 -*-
"""
基于socket的通道
"""
class SocksChannel:
"""
通道类,可以在进程间和进程内通信,双向但同时只能有一个发送者和一个接收者
有两种接收工作方式,但是只能选择一种,主动接收和被动接收,主动接收使用 `receive` 方法,被动接收使用 `on_receive` 装饰器
"""
def __init__(self, name: str):
"""
初始化通道
Args:
name: 通道ID
"""
self._name = name
self._conn_send = None
self._conn_recv = None
self._closed = False
def send(self, data):
"""
发送数据
Args:
data: 数据
"""
pass
def receive(self):
"""
接收数据
Returns:
data: 数据
"""
pass
def close(self):
"""
关闭通道
"""
pass

0
liteyuki/comm/storage.py Normal file → Executable file
View File

51
liteyuki/config.py Normal file → Executable file
View File

@ -11,8 +11,8 @@
import os
import json
import copy
import toml
import yaml
import toml # type: ignore
import yaml # type: ignore
from typing import Any
@ -118,6 +118,8 @@ def load_config_in_default(no_waring: bool = False) -> dict[str, Any]:
从一个标准的轻雪项目加载配置文件
项目目录下的config.*和config目录下的所有配置文件
项目目录下的配置文件优先
Args:
no_waring: 是否关闭警告
"""
config = load_configs_from_dirs("config", no_waring=no_waring)
config.update(
@ -130,3 +132,48 @@ def load_config_in_default(no_waring: bool = False) -> dict[str, Any]:
)
)
return config
# new config loader
class Loader:
def __init__(self):
self.config = {}
def load_from_yaml(self, fp: str) -> "Loader":
"""从yaml文件加载配置
Args:
fp
"""
with open(fp, 'r') as file:
self.config.update(yaml.safe_load(file))
return self
def load_from_toml(self, fp: str) -> "Loader":
"""从toml文件加载配置"""
with open(fp, 'r') as file:
self.config.update(toml.load(file))
return self
def load_from_json(self, fp: str) -> "Loader":
"""从json文件加载配置"""
with open(fp, 'r') as file:
self.config.update(json.load(file))
return self
def load_from_env(self, prefix: str = "") -> "Loader":
"""从环境变量加载配置"""
for key, value in os.environ.items():
if key.startswith(prefix):
self.config[key[len(prefix):]] = value
return self
def merge(self, loader: "Loader") -> "Loader":
"""合并两个Loader键值对树"""
self.config.update(loader.config)
return self
def get(self, key: str, default: Any = None) -> Any:
"""获取配置值"""
return self.config.get(key, default)
def __repr__(self) -> str:
return f"Loader(config={self.config})"

0
liteyuki/core/__init__.py Normal file → Executable file
View File

39
liteyuki/core/manager.py Normal file → Executable file
View File

@ -225,17 +225,14 @@ class ProcessManager:
class _SubProcessManager:
"""
子进程管理器
若要子进程间通信请先在子进程A中发送通信事件给主进程包含当前进程信息及上下文信息主进程再将信息发送给子进程B子进程B再根据信息进行操作
"""
def __init__(self):
self.processes: dict[str, SubProcess] = {}
def new_process(
self, name: str, *args, **kwargs
) -> Callable[[ProcessFuncType], None]:
def decorator(func: ProcessFuncType):
self.processes[name] = SubProcess(name, func, *args, **kwargs)
return decorator
def add(self, name: str, func: ProcessFuncType, *args, **kwargs):
"""
@ -268,5 +265,33 @@ class _SubProcessManager:
process.start()
logger.debug(f"Starting process {name}")
def terminate(self, name: str):
"""
终止指定子进程
Args:
name: 子进程名称
Returns:
"""
if name not in self.processes:
raise KeyError(f"Process {name} not found.")
self.processes[name].terminate()
def terminate_all(self):
"""
终止所有子进程
"""
for name, process in self.processes.items():
process.terminate()
logger.debug(f"Terminating process {name}")
def get_process(self, name: str) -> SubProcess | None:
"""
获取指定子进程
Args:
name: 子进程名称
Returns:
"""
return self.processes.get(name, None)
sub_process_manager = _SubProcessManager()

0
liteyuki/dev/__init__.py Normal file → Executable file
View File

0
liteyuki/dev/observer.py Normal file → Executable file
View File

0
liteyuki/dev/plugin.py Normal file → Executable file
View File

0
liteyuki/exception.py Normal file → Executable file
View File

56
liteyuki/log.py Normal file → Executable file
View File

@ -12,26 +12,34 @@ import sys
import loguru
logger = loguru.logger
logger = loguru.logger.bind()
# DEBUG日志格式
debug_format: str = (
"<c>{time:YYYY-MM-DD HH:mm:ss}</c> "
"<lvl>[{level.icon}]</lvl> "
"<c><{name}.{module}.{function}:{line}></c> "
"{message}"
"<c>{time:YYYY-MM-DD HH:mm:ss}</c> "
"<lvl>[{level.icon}{level}]</lvl> "
"<c><{name}.{module}.{function}:{line}></c> "
"{message}"
)
# 默认日志格式
default_format: str = (
"<c>{time:MM-DD HH:mm:ss}</c> "
"<lvl>[{level.icon}]</lvl> "
"<c><{name}></c> "
"{message}"
"<c>{time:MM-DD HH:mm:ss}</c> "
"<lvl>[{level.icon}{level}]</lvl> "
"<c><{name}></c> "
"{message}"
)
def get_format(level: str) -> str:
"""
获取日志格式
Args:
level: 日志等级
Returns: 日志格式
"""
# DEBUG日志格式
if level == "DEBUG":
return debug_format
else:
@ -41,23 +49,27 @@ def get_format(level: str) -> str:
def init_log(config: dict):
"""
在语言加载完成后执行
Returns:
Args:
config: 配置
"""
global logger
level = config.get("log_level", "DEBUG")
logger.remove()
logger.add(
sys.stdout,
level=0,
level=level,
diagnose=False,
format=get_format(config.get("log_level", "INFO")),
format=get_format(level),
)
show_icon = config.get("log_icon", True)
logger.level("DEBUG", color="<blue>", icon=f"{'🐛' if show_icon else ''}DEBUG")
logger.level("INFO", color="<normal>", icon=f"{'' if show_icon else ''}INFO")
logger.level("SUCCESS", color="<green>", icon=f"{'' if show_icon else ''}SUCCESS")
logger.level("WARNING", color="<yellow>", icon=f"{'⚠️' if show_icon else ''}WARNING")
logger.level("ERROR", color="<red>", icon=f"{'' if show_icon else ''}ERROR")
logger.level("DEBUG", color="<blue>", icon=f"{'🐛' if show_icon else ''}")
logger.level("INFO", color="<normal>", icon=f"{'' if show_icon else ''}")
logger.level("SUCCESS", color="<green>", icon=f"{'' if show_icon else ''}")
logger.level("WARNING", color="<yellow>", icon=f"{'⚠️' if show_icon else ''}")
logger.level("ERROR", color="<red>", icon=f"{'' if show_icon else ''}")
logger.level("CRITICAL", color="<red>", icon=f"{'' if show_icon else ''}")
logger.level("TRACE", color="<cyan>", icon=f"{'🔍' if show_icon else ''}")
logger.bind()
init_log(config={})
init_log(config={"log_level": "DEBUG", "log_icon": True})

View File

@ -1,10 +0,0 @@
# -*- coding: utf-8 -*-
"""
Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
@Time : 2024/8/19 下午10:44
@Author : snowykami
@Email : snowykami@outlook.com
@File : __init__.py.py
@Software: PyCharm
"""

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