From dde30208a814db350b04897ee0ae52635eec74f0 Mon Sep 17 00:00:00 2001 From: Gehongyan Date: Wed, 13 Nov 2024 17:50:18 +0800 Subject: [PATCH] Updated docs for pipe client --- docs/quick_reference/http_api/message.md | 18 ++++++++++++ docs/quick_reference/index.md | 1 + docs/quick_reference/startup/pipe.md | 34 +++++++++++++++++++++++ docs/quick_reference/startup/rest.md | 2 +- docs/quick_reference/startup/websocket.md | 2 +- docs/quick_reference/toc.yml | 2 ++ 6 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 docs/quick_reference/startup/pipe.md diff --git a/docs/quick_reference/http_api/message.md b/docs/quick_reference/http_api/message.md index 18e0788f..d0d06950 100644 --- a/docs/quick_reference/http_api/message.md +++ b/docs/quick_reference/http_api/message.md @@ -10,6 +10,7 @@ title: 消息相关接口 ```csharp readonly KookSocketClient _socketClient = null; readonly KookRestClient _restClient = null; +readonly KookPipeClient _pipeClient = null; SocketTextChannel socketTextChannel = null; @@ -179,6 +180,22 @@ await userMessage.RemoveReactionAsync(emoji, user); await userMessage.RemoveReactionsAsync(user, emojis); ``` +### [发送管道消息] + +POST `/api/v3/message/send-pipemsg` + +```csharp +string content = null; // 要发送到管道的消息文本 +T parameters = default; // 要发送到管道的模板消息的参数 +JsonSerializerOptions jsonSerializerOptions = null; // 要发送到管道的模板消息的参数的序列化选项 + +// API 请求,发送文本内容 +await _pipeClient.SendContentAsync(content); +// API 请求,发送模板消息的参数 +await _pipeClient.SendTemplateAsync(parameters, jsonSerializerOptions); +``` + + [获取频道聊天消息列表]: https://developer.kookapp.cn/doc/http/message#获取频道聊天消息列表 [获取频道聊天消息详情]: https://developer.kookapp.cn/doc/http/message#获取频道聊天消息详情 [发送频道聊天消息]: https://developer.kookapp.cn/doc/http/message#发送频道聊天消息 @@ -187,3 +204,4 @@ await userMessage.RemoveReactionsAsync(user, emojis); [获取频道消息某回应的用户列表]: https://developer.kookapp.cn/doc/http/message#获取频道消息某回应的用户列表 [给某个消息添加回应]: https://developer.kookapp.cn/doc/http/message#给某个消息添加回应 [删除消息的某个回应]: https://developer.kookapp.cn/doc/http/message#删除消息的某个回应 +[发送管道消息]: https://developer.kookapp.cn/doc/http/message#发送管道消息 diff --git a/docs/quick_reference/index.md b/docs/quick_reference/index.md index 77002d36..6485d0d9 100644 --- a/docs/quick_reference/index.md +++ b/docs/quick_reference/index.md @@ -13,6 +13,7 @@ title: 快速参考指南 - @Guides.QuickReference.Startup.Rest - @Guides.QuickReference.Startup.WebSocket - @Guides.QuickReference.Startup.Webhook + - @Guides.QuickReference.Startup.Pipe - HTTP 接口 - @Guides.QuickReference.Http.Guild - @Guides.QuickReference.Http.Channel diff --git a/docs/quick_reference/startup/pipe.md b/docs/quick_reference/startup/pipe.md new file mode 100644 index 00000000..eb9b852d --- /dev/null +++ b/docs/quick_reference/startup/pipe.md @@ -0,0 +1,34 @@ +--- +uid: Guides.QuickReference.Startup.Pipe +title: Pipe 客户端 +--- + +# Pipe 客户端 + +预声明变量 + +```csharp +readonly KookPipeClient _pipeClient; +``` + +```csharp +string accessToken; // 管道访问令牌 +Uri pipeUrl; // 管道回调地址 + +// 使用访问令牌及默认配置创建 Pipe 客户端 +_pipeClient = new KookPipeClient(accessToken); +// 使用回调地址及默认配置创建 Pipe 客户端 +_pipeClient = new KookPipeClient(pipeUrl); +// 使用访问令牌及自定义配置创建 Pipe 客户端 +_pipeClient = new KookPipeClient(accessToken, new KookRestConfig +{ + // KookRestConfig 的全部配置项参见 Rest 客户端页面 +}); +// 使用回调地址及自定义配置创建 Pipe 客户端 +_pipeClient = new KookPipeClient(pipeUrl, new KookRestConfig +{ + // KookRestConfig 的全部配置项参见 Rest 客户端页面 +}); + +// Pipe 客户端不实现 IKookClient 接口,创建即登录 +``` diff --git a/docs/quick_reference/startup/rest.md b/docs/quick_reference/startup/rest.md index 7d8df10f..4d54611c 100644 --- a/docs/quick_reference/startup/rest.md +++ b/docs/quick_reference/startup/rest.md @@ -15,7 +15,7 @@ readonly KookRestClient _restClient; // 使用默认配置创建 Rest 客户端 _restClient = new KookRestClient(); // 使用自定义配置创建 Rest 客户端 -_restClient = new KookRestClient(new KookRestConfig() +_restClient = new KookRestClient(new KookRestConfig { // 请求头 Accept-Language AcceptLanguage = "zh-CN", diff --git a/docs/quick_reference/startup/websocket.md b/docs/quick_reference/startup/websocket.md index 07c39427..2bce0103 100644 --- a/docs/quick_reference/startup/websocket.md +++ b/docs/quick_reference/startup/websocket.md @@ -15,7 +15,7 @@ readonly KookSocketClient _socketClient; // 使用默认配置创建 WebSocket 客户端 _socketClient = new KookRestClient(); // 使用自定义配置创建 WebSocket 客户端 -_socketClient = new KookSocketClient(new KookSocketConfig() +_socketClient = new KookSocketClient(new KookSocketConfig { // 包含 KookRestConfig 的全部配置项,此处略 diff --git a/docs/quick_reference/toc.yml b/docs/quick_reference/toc.yml index 1a59780a..22c7c051 100644 --- a/docs/quick_reference/toc.yml +++ b/docs/quick_reference/toc.yml @@ -8,6 +8,8 @@ topicUid: Guides.QuickReference.Startup.WebSocket - name: Webhook 服务端 topicUid: Guides.QuickReference.Startup.Webhook + - name: Pipe 客户端 + topicUid: Guides.QuickReference.Startup.Pipe - name: HTTP 接口 items: - name: 服务器相关接口