Skip to content

Commit

Permalink
[OneBot] Implemented VideoSegment.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Feb 2, 2024
1 parent e7d50c3 commit 4749fe0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Lagrange.OneBot/Core/Message/Entity/ImageSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion Lagrange.OneBot/Core/Message/Entity/RecordSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
34 changes: 34 additions & 0 deletions Lagrange.OneBot/Core/Message/Entity/VideoSegment.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Please use Lagrange.Core responsibly and in accordance with the law.
| | | UnusalDevice<br/>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 | 🔴 |
Expand All @@ -62,7 +62,7 @@ Please use Lagrange.Core responsibly and in accordance with the law.
| [Face] | 🟢 |
| [Image] | 🟢 |
| [Record] | 🟡 |
| [Video] | 🔴 |
| [Video] | 🟡 |
| [At] | 🟢 |
| [Rps] | 🔴 |
| [Dice] | 🔴 |
Expand Down

0 comments on commit 4749fe0

Please sign in to comment.