From 9306de8b80c25d07a6584f4149f9ca56237361a7 Mon Sep 17 00:00:00 2001 From: milimoe Date: Wed, 6 May 2026 01:34:21 +0800 Subject: [PATCH] =?UTF-8?q?md=20=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models => OshimaServers/Model}/QQBot.cs | 284 +++++++++++- OshimaServers/Service/FunGameService.cs | 30 +- OshimaWebAPI/Controllers/FunGameController.cs | 123 +++++- OshimaWebAPI/Controllers/QQBotController.cs | 44 +- OshimaWebAPI/OshimaWebAPI.cs | 2 +- OshimaWebAPI/Services/QQBotService.cs | 2 +- OshimaWebAPI/Services/RainBOTService.cs | 418 ++++++++++-------- 7 files changed, 673 insertions(+), 230 deletions(-) rename {OshimaWebAPI/Models => OshimaServers/Model}/QQBot.cs (50%) diff --git a/OshimaWebAPI/Models/QQBot.cs b/OshimaServers/Model/QQBot.cs similarity index 50% rename from OshimaWebAPI/Models/QQBot.cs rename to OshimaServers/Model/QQBot.cs index b1be436..f0c0eaf 100644 --- a/OshimaWebAPI/Models/QQBot.cs +++ b/OshimaServers/Model/QQBot.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace Oshima.FunGame.WebAPI.Models +namespace Oshima.FunGame.OshimaServers.Models { public class Payload { @@ -87,6 +87,149 @@ namespace Oshima.FunGame.WebAPI.Models public string ImageUrl { get; set; } } + public class BotReply + { + // 纯文本内容(兼容旧版) + public string? Text { get; set; } + + // Markdown 消息(与 Text 互斥,若提供则发送 Markdown) + public MarkdownMessage? Markdown { get; set; } + + // Markdown 附带键盘(仅当 Markdown 不为 null 时有效) + public KeyboardMessage? Keyboard { get; set; } + + // 方便从 string 隐式转换,旧代码无感知 + public static implicit operator BotReply(string text) => new() { Text = text }; + } + + public static class BotReplyExtension + { + /// + /// 增加键盘按钮 + /// + /// 键盘消息 + /// 每行按钮数量,自动检查如果超过则新建行 + /// 按钮 + /// + public static KeyboardMessage AppendButtons(this KeyboardMessage kb, int btnCountPerRow, params IEnumerable