📝 文档新增插件通信部分内容
Some checks failed
Deploy VitePress site to Pages / build (push) Failing after 1m10s

This commit is contained in:
远野千束 2024-10-26 02:34:58 +08:00
parent 4510477026
commit 7bf94a15c8
7 changed files with 61 additions and 69 deletions

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

View File

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

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)提供的字体,且遵守了相关字体开源协议

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 里,有部分实现插件为了一些功能在子进程中运行,这样两个进程上下文是不会互相干扰的,因此无法通过共享内存和直接对象传递进行通信。
例如子进程接收到用户信息需要重启机器人,这时可以通过通道对主进程发送消息,主进程接收到消息后重启对应子进程。

View File

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

View File

@ -0,0 +1,15 @@
from typing import Any
from pydantic import BaseModel
class BaseSeg(BaseModel):
type: str = "Segment"
data: dict[str, Any]
class Text(BaseSeg):
content: str
class Image(BaseSeg):
url: str

View File

@ -0,0 +1,26 @@
import os.path
from pathlib import Path
from croterline.utils import IsMainProcess
from liteyuki.core import sub_process_manager
from liteyuki.plugin import PluginMetadata, PluginType
__plugin_meta__ = PluginMetadata(
name="MeloBot3",
type=PluginType.APPLICATION,
)
def mb_run(*args, **kwargs):
pass
if IsMainProcess:
from liteyuki import get_bot
bot = get_bot()
sub_process_manager.add(
name="melobot", func=mb_run, **bot.config.get("melobot", {})
)