-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OneBot] Implemented VideoSegment.cs
- Loading branch information
Linwenxuan
authored and
Linwenxuan
committed
Feb 2, 2024
1 parent
e7d50c3
commit 4749fe0
Showing
4 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters