Compare commits
51 Commits
Author | SHA1 | Date | |
---|---|---|---|
c9a4683e98 | |||
317e07eb71 | |||
37749ae15e | |||
f94c10de61 | |||
5ccef735be | |||
262002b49a | |||
40c6ba6d9e | |||
60093b562b | |||
30880ec13b | |||
cc1d82312a | |||
efca13d397 | |||
3a8c09d6db | |||
cc1bb8e5e4 | |||
93c17b6026 | |||
fd3f6272f1 | |||
4d87a3c0b7 | |||
86f47ee411 | |||
1d6b8d60f3 | |||
3890704045 | |||
b0761e9873 | |||
291314de93 | |||
fd835e9406 | |||
d681c5645a | |||
d0619f1fe8 | |||
b022a364e3 | |||
df00c61dd8 | |||
94a021bab0 | |||
6b20e9eae0 | |||
0a35a3c6f8 | |||
2e75c7bc65 | |||
3341505715 | |||
bdde9c45fd | |||
7bf94a15c8 | |||
4510477026 | |||
86e50e369b | |||
796fc6f233 | |||
80c6875567 | |||
ab89cd1c72 | |||
5e454bc971 | |||
70bfb0fcee | |||
13b95c2732 | |||
ef5866343d | |||
d5ccd105a2 | |||
20ad8dc53f | |||
de9c91d8bd | |||
6b64a0c379 | |||
f117da7ff3 | |||
f548a07230 | |||
e2e53c21fa | |||
3eaf23a56b | |||
4a5dd1f727 |
0
.dockerignore
Normal file → Executable file
0
.dockerignore
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/resource_publish_en.yml
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/resource_publish_en.yml
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/resource_publish_zh.yml
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/resource_publish_zh.yml
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/问题反馈.md
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/问题反馈.md
vendored
Normal file → Executable file
0
.github/dependabot.yml
vendored
Normal file → Executable file
0
.github/dependabot.yml
vendored
Normal file → Executable file
43
.github/workflows/build-image.yml
vendored
Executable file
43
.github/workflows/build-image.yml
vendored
Executable 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
0
.github/workflows/deploy-docs.yml
vendored
Normal file → Executable file
0
.github/workflows/issue_handler.yml
vendored
Normal file → Executable file
0
.github/workflows/issue_handler.yml
vendored
Normal file → Executable file
30
.github/workflows/pre-commit.yml
vendored
Executable file
30
.github/workflows/pre-commit.yml
vendored
Executable 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
0
.github/workflows/pypi-publish.yml
vendored
Normal file → Executable file
11
.gitignore
vendored
Normal file → Executable file
11
.gitignore
vendored
Normal file → Executable 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
26
.pre-commit-config.yaml
Executable 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
6
Dockerfile
Normal file → Executable 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
|
||||
|
||||
|
50
README.md
Normal file → Executable file
50
README.md
Normal file → Executable 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
6
config/default.yml
Normal file → Executable 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
12
docker-compose.yml
Executable 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
0
docker/sources.list
Normal file → Executable file
27
docs/.vitepress/config/common.ts
Normal file → Executable file
27
docs/.vitepress/config/common.ts
Normal file → Executable 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
2
docs/.vitepress/config/en.ts
Normal file → Executable 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
0
docs/.vitepress/config/index.ts
Normal file → Executable file
0
docs/.vitepress/config/utils.ts
Normal file → Executable file
0
docs/.vitepress/config/utils.ts
Normal file → Executable file
2
docs/.vitepress/config/zh.ts
Normal file → Executable file
2
docs/.vitepress/config/zh.ts
Normal file → Executable 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
0
docs/.vitepress/theme/index.ts
Normal file → Executable file
0
docs/.vitepress/theme/liteyuki.scss
Normal file → Executable file
0
docs/.vitepress/theme/liteyuki.scss
Normal file → Executable file
0
docs/components/ContributorBar.vue
Normal file → Executable file
0
docs/components/ContributorBar.vue
Normal file → Executable file
0
docs/components/Dash.vue
Normal file → Executable file
0
docs/components/Dash.vue
Normal file → Executable file
0
docs/components/Geo.vue
Normal file → Executable file
0
docs/components/Geo.vue
Normal file → Executable file
0
docs/components/Home.vue
Normal file → Executable file
0
docs/components/Home.vue
Normal file → Executable file
0
docs/components/PluginItemCard.vue
Normal file → Executable file
0
docs/components/PluginItemCard.vue
Normal file → Executable file
0
docs/components/PluginStore.vue
Normal file → Executable file
0
docs/components/PluginStore.vue
Normal file → Executable file
0
docs/components/ResItemCard.vue
Normal file → Executable file
0
docs/components/ResItemCard.vue
Normal file → Executable file
0
docs/components/ResPubWindow.vue
Normal file → Executable file
0
docs/components/ResPubWindow.vue
Normal file → Executable file
0
docs/components/ResStore.vue
Normal file → Executable file
0
docs/components/ResStore.vue
Normal file → Executable file
0
docs/components/StatsBar.vue
Normal file → Executable file
0
docs/components/StatsBar.vue
Normal file → Executable file
0
docs/components/Tabs.vue
Normal file → Executable file
0
docs/components/Tabs.vue
Normal file → Executable file
0
docs/components/ToggleSwitch.vue
Normal file → Executable file
0
docs/components/ToggleSwitch.vue
Normal file → Executable file
0
docs/components/TryLiteyukiWindow.vue
Normal file → Executable file
0
docs/components/TryLiteyukiWindow.vue
Normal file → Executable file
0
docs/components/scripts/const.ts
Normal file → Executable file
0
docs/components/scripts/const.ts
Normal file → Executable file
0
docs/components/scripts/i18n.ts
Normal file → Executable file
0
docs/components/scripts/i18n.ts
Normal file → Executable file
0
docs/components/scripts/statsApi.ts
Normal file → Executable file
0
docs/components/scripts/statsApi.ts
Normal file → Executable file
0
docs/en/deploy/config.md
Normal file → Executable file
0
docs/en/deploy/config.md
Normal file → Executable file
34
docs/en/deploy/fandq.md
Normal file → Executable file
34
docs/en/deploy/fandq.md
Normal file → Executable 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
29
docs/en/deploy/install.md
Normal file → Executable 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 `$(pwd)` <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
0
docs/en/dev/best_practices.md
Normal file → Executable file
0
docs/en/dev/comm.md
Normal file → Executable file
0
docs/en/dev/comm.md
Normal file → Executable file
0
docs/en/dev/guide.md
Normal file → Executable file
0
docs/en/dev/guide.md
Normal file → Executable file
0
docs/en/dev/lyfunc.md
Normal file → Executable file
0
docs/en/dev/lyfunc.md
Normal file → Executable file
4
docs/en/dev/plugin.md
Normal file → Executable file
4
docs/en/dev/plugin.md
Normal file → Executable file
@ -1,11 +1,11 @@
|
||||
---
|
||||
title: Liteyuki Plugin
|
||||
title: Plugin
|
||||
order: 3
|
||||
---
|
||||
|
||||
# 简介
|
||||
|
||||
轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能
|
||||
轻雪插件是轻雪内置的一部分功能,运行在主进程中,可以很高程度地扩展轻雪的功能。
|
||||
|
||||
## 开始
|
||||
|
||||
|
0
docs/en/dev/resource.md
Normal file → Executable file
0
docs/en/dev/resource.md
Normal file → Executable file
0
docs/en/index.md
Normal file → Executable file
0
docs/en/index.md
Normal file → Executable file
0
docs/en/store/plugin.md
Normal file → Executable file
0
docs/en/store/plugin.md
Normal file → Executable file
0
docs/en/store/resource.md
Normal file → Executable file
0
docs/en/store/resource.md
Normal file → Executable file
0
docs/en/usage/agreement.md
Normal file → Executable file
0
docs/en/usage/agreement.md
Normal file → Executable file
0
docs/en/usage/basic.md
Normal file → Executable file
0
docs/en/usage/basic.md
Normal file → Executable file
0
docs/en/usage/extra.md
Normal file → Executable file
0
docs/en/usage/extra.md
Normal file → Executable file
0
docs/package.json
Normal file → Executable file
0
docs/package.json
Normal file → Executable file
2248
docs/pnpm-lock.yaml
generated
Normal file → Executable 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
0
docs/public/favicon.ico
Normal file → Executable file
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
0
docs/public/liteyuki-dark.svg
Normal file → Executable file
0
docs/public/liteyuki-dark.svg
Normal file → Executable file
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
0
docs/public/liteyuki.svg
Normal file → Executable file
0
docs/public/liteyuki.svg
Normal file → Executable file
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
0
docs/public/plugins.json
Normal file → Executable file
0
docs/public/plugins.json
Normal file → Executable file
0
docs/public/resources.json
Normal file → Executable file
0
docs/public/resources.json
Normal file → Executable file
0
docs/tsconfig.json
Normal file → Executable file
0
docs/tsconfig.json
Normal file → Executable file
2
docs/zh/deploy/config.md
Normal file → Executable file
2
docs/zh/deploy/config.md
Normal file → Executable 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
35
docs/zh/deploy/fandq.md
Normal file → Executable 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
33
docs/zh/deploy/install.md
Normal file → Executable 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
0
docs/zh/dev/best_practices.md
Normal file → Executable file
4
docs/zh/dev/comm.md
Normal file → Executable file
4
docs/zh/dev/comm.md
Normal file → Executable 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
0
docs/zh/dev/guide.md
Normal file → Executable file
0
docs/zh/dev/lyfunc.md
Normal file → Executable file
0
docs/zh/dev/lyfunc.md
Normal file → Executable file
12
docs/zh/dev/plugin.md
Normal file → Executable file
12
docs/zh/dev/plugin.md
Normal file → Executable 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
0
docs/zh/dev/resource.md
Normal file → Executable file
0
docs/zh/index.md
Normal file → Executable file
0
docs/zh/index.md
Normal file → Executable file
0
docs/zh/store/plugin.md
Normal file → Executable file
0
docs/zh/store/plugin.md
Normal file → Executable file
0
docs/zh/store/resource.md
Normal file → Executable file
0
docs/zh/store/resource.md
Normal file → Executable file
0
docs/zh/usage/agreement.md
Normal file → Executable file
0
docs/zh/usage/agreement.md
Normal file → Executable file
0
docs/zh/usage/basic.md
Normal file → Executable file
0
docs/zh/usage/basic.md
Normal file → Executable file
0
docs/zh/usage/extra.md
Normal file → Executable file
0
docs/zh/usage/extra.md
Normal file → Executable file
0
liteyuki/EN.LICENSE
Normal file → Executable file
0
liteyuki/EN.LICENSE
Normal file → Executable file
0
liteyuki/LICENSE
Normal file → Executable file
0
liteyuki/LICENSE
Normal file → Executable file
0
liteyuki/__init__.py
Normal file → Executable file
0
liteyuki/__init__.py
Normal file → Executable file
32
liteyuki/bot/__init__.py
Normal file → Executable file
32
liteyuki/bot/__init__.py
Normal file → Executable 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
0
liteyuki/bot/lifespan.py
Normal file → Executable file
0
liteyuki/comm/__init__.py
Normal file → Executable file
0
liteyuki/comm/__init__.py
Normal file → Executable file
5
liteyuki/comm/channel.py
Normal file → Executable file
5
liteyuki/comm/channel.py
Normal file → Executable 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
0
liteyuki/comm/event.py
Normal file → Executable 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
0
liteyuki/comm/storage.py
Normal file → Executable file
51
liteyuki/config.py
Normal file → Executable file
51
liteyuki/config.py
Normal file → Executable 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
0
liteyuki/core/__init__.py
Normal file → Executable file
39
liteyuki/core/manager.py
Normal file → Executable file
39
liteyuki/core/manager.py
Normal file → Executable 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
0
liteyuki/dev/__init__.py
Normal file → Executable file
0
liteyuki/dev/observer.py
Normal file → Executable file
0
liteyuki/dev/observer.py
Normal file → Executable file
0
liteyuki/dev/plugin.py
Normal file → Executable file
0
liteyuki/dev/plugin.py
Normal file → Executable file
0
liteyuki/exception.py
Normal file → Executable file
0
liteyuki/exception.py
Normal file → Executable file
56
liteyuki/log.py
Normal file → Executable file
56
liteyuki/log.py
Normal file → Executable 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})
|
@ -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
Reference in New Issue
Block a user