using System.Text.Json.Serialization;
namespace Oshima.FunGame.OshimaServers.Models
{
public class Payload
{
[JsonPropertyName("id")]
public string Id { get; set; } = "";
[JsonPropertyName("op")]
public int Op { get; set; } = 0;
[JsonPropertyName("d")]
public object Data { get; set; } = new();
[JsonPropertyName("s")]
public int SequenceNumber { get; set; } = 0;
[JsonPropertyName("t")]
public string EventType { get; set; } = "";
}
public class ValidationRequest
{
[JsonPropertyName("plain_token")]
public string PlainToken { get; set; } = "";
[JsonPropertyName("event_ts")]
public string EventTs { get; set; } = "";
}
public class ValidationResponse
{
[JsonPropertyName("plain_token")]
public string PlainToken { get; set; } = "";
[JsonPropertyName("signature")]
public string Signature { get; set; } = "";
}
public class BotConfig
{
public string AppId { get; set; } = "";
public string Secret { get; set; } = "";
}
public class Author
{
[JsonPropertyName("user_openid")]
public string UserOpenId { get; set; } = "";
[JsonPropertyName("member_openid")]
public string MemberOpenId { get; set; } = "";
}
public class Attachment
{
[JsonPropertyName("content_type")]
public string ContentType { get; set; } = "";
[JsonPropertyName("filename")]
public string Filename { get; set; } = "";
[JsonPropertyName("height")]
public int Height { get; set; } = 0;
[JsonPropertyName("width")]
public int Width { get; set; } = 0;
[JsonPropertyName("size")]
public int Size { get; set; } = 0;
[JsonPropertyName("url")]
public string Url { get; set; } = "";
}
public interface IBotMessage
{
public string Id { get; }
public bool IsGroup { get; }
public string Detail { get; set; }
public string Timestamp { get; }
public string OpenId { get; }
public string AuthorOpenId { get; }
public long FunGameUID { get; set; }
public bool UseNotice { get; set; }
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