-
Notifications
You must be signed in to change notification settings - Fork 277
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
Feb 2, 2024
1 parent
eb5f682
commit 1c2d4f5
Showing
2 changed files
with
70 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Text.Json.Serialization; | ||
using Lagrange.Core.Message; | ||
using Lagrange.Core.Message.Entity; | ||
|
||
namespace Lagrange.OneBot.Core.Message.Entity; | ||
|
||
[Serializable] | ||
public partial class PokeSegment(uint type) | ||
{ | ||
public PokeSegment() : this(0) { } | ||
|
||
[JsonPropertyName("type")] [CQProperty] public uint Type { get; set; } = type; | ||
|
||
[JsonPropertyName("id")] [CQProperty] public uint Id { get; set; } | ||
} | ||
|
||
[SegmentSubscriber(typeof(PokeEntity), "poke")] | ||
public partial class PokeSegment : ISegment | ||
{ | ||
public IMessageEntity ToEntity() => new PokeEntity(Type); | ||
|
||
public void Build(MessageBuilder builder, ISegment segment) | ||
{ | ||
if (segment is PokeSegment pokeSegment) builder.Poke(pokeSegment.Type); | ||
} | ||
|
||
public ISegment FromEntity(IMessageEntity entity) | ||
{ | ||
if (entity is not PokeEntity pokeEntity) throw new ArgumentException("Invalid entity type."); | ||
|
||
return new PokeSegment(pokeEntity.Type); | ||
} | ||
} |
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