diff --git a/Lagrange.Core/Common/Entity/BotGroupReaction.cs b/Lagrange.Core/Common/Entity/BotGroupReaction.cs new file mode 100644 index 000000000..ec0ebdff8 --- /dev/null +++ b/Lagrange.Core/Common/Entity/BotGroupReaction.cs @@ -0,0 +1,20 @@ +namespace Lagrange.Core.Common.Entity; + +public class BotGroupReaction +{ + public string FaceId { get; set; } + + public uint Type { get; set; } + + public uint Count { get; set; } + + public bool IsAdded { get; set; } + + public BotGroupReaction(string faceId, uint type, uint count, bool isAdded) + { + FaceId = faceId; + Type = type; + Count = count; + IsAdded = isAdded; + } +} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Packets/Message/Element/Implementation/Extra/GroupReactionExtra.cs b/Lagrange.Core/Internal/Packets/Message/Element/Implementation/Extra/GroupReactionExtra.cs new file mode 100644 index 000000000..7973ffffe --- /dev/null +++ b/Lagrange.Core/Internal/Packets/Message/Element/Implementation/Extra/GroupReactionExtra.cs @@ -0,0 +1,41 @@ +#pragma warning disable CS8618 + +using ProtoBuf; + +namespace Lagrange.Core.Internal.Packets.Message.Element.Implementation.Extra; + +[ProtoContract] +internal class GroupReactionExtra +{ + [ProtoMember(1)] public GroupReactionExtraBody Body { get; set; } +} + +[ProtoContract] +internal class GroupReactionExtraBody +{ + [ProtoMember(1)] public GroupReactionExtraBodyField1 Field1 { get; set; } + + [ProtoMember(2)] public GroupReactionExtraFaceInfo[] FaceInfos { get; set; } +} + +[ProtoContract] +internal class GroupReactionExtraBodyField1 +{ + [ProtoMember(1)] public uint Field1 { get; set; } + + [ProtoMember(2)] public uint Field2 { get; set; } +} + +[ProtoContract] +internal class GroupReactionExtraFaceInfo +{ + // See Lagrange.Core/Internal/Service/System/FetchFullSysFacesService.cs + [ProtoMember(1)] public string FaceId { get; set; } + + // See Lagrange.Core/Internal/Service/System/FetchFullSysFacesService.cs + [ProtoMember(2)] public uint Type { get; set; } + + [ProtoMember(3)] public uint Count { get; set; } + + [ProtoMember(4)] public uint IsAdded { get; set; } +} \ No newline at end of file diff --git a/Lagrange.Core/Message/Entity/GroupReactionEntity.cs b/Lagrange.Core/Message/Entity/GroupReactionEntity.cs new file mode 100644 index 000000000..4944a44c2 --- /dev/null +++ b/Lagrange.Core/Message/Entity/GroupReactionEntity.cs @@ -0,0 +1,67 @@ +using Lagrange.Core.Common.Entity; +using Lagrange.Core.Internal.Packets.Message.Element; +using Lagrange.Core.Internal.Packets.Message.Element.Implementation; +using Lagrange.Core.Internal.Packets.Message.Element.Implementation.Extra; +using ProtoBuf; + +namespace Lagrange.Core.Message.Entity; + +[MessageElement(typeof(CommonElem))] +public class GroupReactionEntity : IMessageEntity +{ + private readonly IEnumerable _reactions; + + public GroupReactionEntity() { _reactions = Array.Empty(); } + + public GroupReactionEntity(IEnumerable reactions) + { + _reactions = reactions; + } + + IEnumerable IMessageEntity.PackElement() + { + var infos = _reactions + .Select(reaction => new GroupReactionExtraFaceInfo() + { + FaceId = reaction.FaceId, + Type = reaction.Type, + Count = reaction.Count, + IsAdded = reaction.IsAdded ? 1u : 0u, + }) + .ToArray(); + + var extra = new GroupReactionExtra + { + Body = new() + { + Field1 = new() + { + Field1 = 0, + Field2 = 7240 + }, + FaceInfos = infos, + } + }; + using var stream = new MemoryStream(); + Serializer.Serialize(stream, extra); + + return new Elem[] { + new() { CommonElem = new() { + ServiceType = 38, + PbElem = stream.ToArray(), + BusinessType = 1 + } } + }; + } + + string IMessageEntity.ToPreviewString() + { + return ""; + } + + IMessageEntity? IMessageEntity.UnpackElement(Elem elem) + { + // TODO Parase + return null; + } +} \ No newline at end of file