using System.Text.Json.Serialization; namespace Oshima.FunGame.WebAPI.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 ThirdPartyMessage : IBotMessage { [JsonPropertyName("id")] public string Id { get; set; } = ""; [JsonPropertyName("isgroup")] public bool IsGroup { get; set; } = false; [JsonPropertyName("group_openid")] public string GroupOpenId { get; set; } = ""; [JsonPropertyName("detail")] public string Detail { get; set; } = ""; [JsonPropertyName("timestamp")] public string Timestamp { get; set; } = ""; [JsonPropertyName("openid")] public string OpenId { get; set; } = ""; [JsonPropertyName("authoropenid")] public string AuthorOpenId { get; set; } = ""; [JsonIgnore] public bool IsCompleted { get; set; } = false; [JsonIgnore] public string Result { get; set; } = ""; [JsonIgnore] public long FunGameUID { get; set; } = 0; [JsonIgnore] public bool UseNotice { get; set; } = true; [JsonIgnore] public string ImageUrl { get; set; } = ""; } public class C2CMessage : IBotMessage { [JsonPropertyName("id")] public string Id { get; set; } = ""; [JsonPropertyName("author")] public Author Author { get; set; } = new(); [JsonPropertyName("content")] public string Content { get; set; } = ""; [JsonPropertyName("timestamp")] public string Timestamp { get; set; } = ""; [JsonPropertyName("attachments")] public Attachment[] Attachments { get; set; } = []; [JsonIgnore] public long FunGameUID { get; set; } = 0; [JsonIgnore] public bool UseNotice { get; set; } = true; [JsonIgnore] public string ImageUrl { get; set; } = ""; public string Detail { get => Content; set => Content = value; } public string OpenId => Author.UserOpenId; public bool IsGroup => false; public string AuthorOpenId => Author.UserOpenId; } public class GroupAtMessage : IBotMessage { [JsonPropertyName("id")] public string Id { get; set; } = ""; [JsonPropertyName("author")] public Author Author { get; set; } = new(); [JsonPropertyName("content")] public string Content { get; set; } = ""; [JsonPropertyName("timestamp")] public string Timestamp { get; set; } = ""; [JsonPropertyName("group_openid")] public string GroupOpenId { get; set; } = ""; [JsonPropertyName("attachments")] public Attachment[] Attachments { get; set; } = []; [JsonIgnore] public long FunGameUID { get; set; } = 0; [JsonIgnore] public bool UseNotice { get; set; } = true; [JsonIgnore] public string ImageUrl { get; set; } = ""; public string Detail { get => Content; set => Content = value; } public string OpenId => GroupOpenId; public bool IsGroup => true; public string AuthorOpenId => Author.MemberOpenId; } public class MediaResponse { [JsonPropertyName("file_uuid")] public string FileUuid { get; set; } = ""; [JsonPropertyName("file_info")] public string FileInfo { get; set; } = ""; [JsonPropertyName("ttl")] public int Ttl { get; set; } } public class UploadMediaResult { /// /// 文件 UUID,成功时有值 /// public string? FileUuid { get; set; } /// /// 文件信息,成功时有值 /// public string? FileInfo { get; set; } /// /// 有效期(秒) /// public int Ttl { get; set; } /// /// 错误信息,成功时为 null /// public string? Error { get; set; } /// /// 是否上传成功 /// [JsonIgnore] public bool IsSuccess => string.IsNullOrEmpty(Error); } public class AccessTokenResponse { [JsonPropertyName("access_token")] public string AccessToken { get; set; } = ""; [JsonPropertyName("expires_in")] public string ExpiresIn { get; set; } = ""; } public class OtherData { public string RequestUrl { get; set; } = ""; } public class MarkdownMessage { /// /// 自定义 Markdown(和模板 ID 互斥,只能用一种方式) /// [JsonPropertyName("content")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? Content { get; set; } /// /// 模板 ID /// [JsonPropertyName("custom_template_id")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? CustomTemplateId { get; set; } /// /// 模板参数列表(仅在模板模式下使用) /// [JsonPropertyName("params")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public List? Params { get; set; } } public class MarkdownParam { [JsonPropertyName("key")] public string Key { get; set; } = ""; [JsonPropertyName("values")] public List Values { get; set; } = []; } public class KeyboardMessage { /// /// 模板按钮 ID(与 content 互斥) /// [JsonPropertyName("id")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? Id { get; set; } /// /// 自定义按钮内容 /// [JsonPropertyName("content")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public KeyboardContent? Content { get; set; } } public class KeyboardContent { [JsonPropertyName("rows")] public List Rows { get; set; } = []; } public class Row { [JsonPropertyName("buttons")] public List