-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Linwenxuan
authored and
Linwenxuan
committed
Oct 12, 2023
1 parent
5ee7d28
commit dc2589e
Showing
20 changed files
with
244 additions
and
217 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
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,11 @@ | ||
using System.Text.Json.Serialization; | ||
using Lagrange.OneBot.Core.Message; | ||
|
||
namespace Lagrange.OneBot.Core.Entity.Message; | ||
|
||
public class OneBotSegment(string type, ISegment data) | ||
{ | ||
[JsonPropertyName("type")] public string Type { get; set; } = type; | ||
|
||
[JsonPropertyName("data")] public object Data { get; set; } = data; | ||
} |
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
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
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,26 @@ | ||
using System.Text.Json.Serialization; | ||
using Lagrange.Core.Message; | ||
using Lagrange.Core.Message.Entity; | ||
|
||
namespace Lagrange.OneBot.Core.Message.Entity; | ||
|
||
[Serializable] | ||
public partial class ImageSegment(string url) | ||
{ | ||
public ImageSegment() : this("") { } | ||
|
||
[JsonPropertyName("file")] public string Url { get; set; } = url; | ||
} | ||
|
||
[SegmentSubscriber(typeof(ImageEntity), "image")] | ||
public partial class ImageSegment : ISegment | ||
{ | ||
public IMessageEntity ToEntity() => new ImageEntity(url); | ||
|
||
public ISegment FromEntity(IMessageEntity entity) | ||
{ | ||
if (entity is not ImageEntity imageEntity) throw new ArgumentException("Invalid entity type."); | ||
|
||
return new ImageSegment(imageEntity.ImageUrl); | ||
} | ||
} |
Oops, something went wrong.