submodule对gitea不管用,所以直接拉了一份拉格兰

This commit is contained in:
2025-02-04 16:29:43 +08:00
parent b0bfc803e3
commit d149a2ea0f
1023 changed files with 43308 additions and 18 deletions

View File

@@ -0,0 +1,33 @@
using System.Text.Json.Serialization;
using Lagrange.Core.Message;
using Lagrange.Core.Message.Entity;
namespace Lagrange.OneBot.Message.Entity;
[Serializable]
public partial class PokeSegment(uint type, uint strength)
{
public PokeSegment() : this(0, 0) { }
[JsonPropertyName("type")] [CQProperty] public string Type { get; set; } = type.ToString();
[JsonPropertyName("strength")] public string? Strength { get; set; } = strength.ToString();
[JsonPropertyName("id")] [CQProperty] public string Id { get; set; } = "-1"; // can not get id
}
[SegmentSubscriber(typeof(PokeEntity), "poke")]
public partial class PokeSegment : SegmentBase
{
public override void Build(MessageBuilder builder, SegmentBase segment)
{
if (segment is PokeSegment pokeSegment) builder.Poke(uint.Parse(pokeSegment.Type), pokeSegment.Strength == null ? 0 : uint.Parse(pokeSegment.Strength));
}
public override SegmentBase FromEntity(MessageChain chain, IMessageEntity entity)
{
if (entity is not PokeEntity pokeEntity) throw new ArgumentException("Invalid entity type.");
return new PokeSegment(pokeEntity.Type, pokeEntity.Strength);
}
}