diff --git a/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs b/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs index 6b4eb7458..19cbae6a1 100644 --- a/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs +++ b/Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs @@ -15,7 +15,7 @@ public ImageSegment() : this("") { } [SegmentSubscriber(typeof(ImageEntity), "image")] public partial class ImageSegment : ISegment { - public IMessageEntity ToEntity() => new ImageEntity(url); + public IMessageEntity ToEntity() => new ImageEntity(Url); public void Build(MessageBuilder builder, ISegment segment) { diff --git a/Lagrange.OneBot/Core/Message/Entity/RecordSegment.cs b/Lagrange.OneBot/Core/Message/Entity/RecordSegment.cs index eb59b808d..c9ad92838 100644 --- a/Lagrange.OneBot/Core/Message/Entity/RecordSegment.cs +++ b/Lagrange.OneBot/Core/Message/Entity/RecordSegment.cs @@ -15,7 +15,7 @@ public RecordSegment() : this("") { } [SegmentSubscriber(typeof(RecordEntity), "record")] public partial class RecordSegment : ISegment { - public IMessageEntity ToEntity() => new ImageEntity(url); + public IMessageEntity ToEntity() => new RecordEntity(Url); public void Build(MessageBuilder builder, ISegment segment) { diff --git a/Lagrange.OneBot/Core/Message/Entity/VideoSegment.cs b/Lagrange.OneBot/Core/Message/Entity/VideoSegment.cs new file mode 100644 index 000000000..dc303fc3a --- /dev/null +++ b/Lagrange.OneBot/Core/Message/Entity/VideoSegment.cs @@ -0,0 +1,34 @@ +using System.Text.Json.Serialization; +using Lagrange.Core.Message; +using Lagrange.Core.Message.Entity; + +namespace Lagrange.OneBot.Core.Message.Entity; + +[Serializable] +public partial class VideoSegment(string url) +{ + public VideoSegment() : this("") { } + + [JsonPropertyName("file")] public string Url { get; set; } = url; +} + +[SegmentSubscriber(typeof(VideoEntity), "video")] +public partial class VideoSegment : ISegment +{ + public IMessageEntity ToEntity() => new VideoEntity(Url); + + public void Build(MessageBuilder builder, ISegment segment) + { + if (segment is VideoSegment videoSegment and not { Url: "" } && CommonResolver.Resolve(videoSegment.Url) is { } image) + { + // TODO: Add Video + } + } + + public ISegment FromEntity(IMessageEntity entity) + { + if (entity is not VideoEntity videoEntity) throw new ArgumentException("Invalid entity type."); + + return new RecordSegment(videoEntity.VideoUrl); + } +} \ No newline at end of file diff --git a/README.md b/README.md index 2f710fce2..f6a1c9f96 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Please use Lagrange.Core responsibly and in accordance with the law. | | | UnusalDevice
Easy | 🟢 | Json | 🟡 | Kick Member | 🟢 | ~~Poke~~ | 🔴 | | | | NewDeviceVerify | 🔴 | Xml | 🟢 | Mute Member | 🟢 | MessageRecall | 🔴 | | | | | | Forward | 🟢 | Set Admin | 🟢 | GroupMemberDecrease | 🟢 | -| | | | | Video | 🔴 | Friend Request | 🔴 | GroupMemberIncrease | 🟢 | +| | | | | Video | 🟡 | Friend Request | 🔴 | GroupMemberIncrease | 🟢 | | | | | | ~~Flash Image~~ | 🔴 | Group Request | 🟢 | GroupPromoteAdmin | 🟢 | | | | | | Reply | 🟢 | ~~Voice Call~~ | 🔴 | GroupInvite | 🟢 | | | | | | File | 🟡 | Client Key | 🟢 | GroupRequestJoin | 🔴 | @@ -62,7 +62,7 @@ Please use Lagrange.Core responsibly and in accordance with the law. | [Face] | 🟢 | | [Image] | 🟢 | | [Record] | 🟡 | -| [Video] | 🔴 | +| [Video] | 🟡 | | [At] | 🟢 | | [Rps] | 🔴 | | [Dice] | 🔴 |