diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/FriendRecallMessageProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/FriendRecallMessageProcessor.cs similarity index 94% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/FriendRecallMessageProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/FriendRecallMessageProcessor.cs index 259865a9..26b165bf 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/FriendRecallMessageProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/FriendRecallMessageProcessor.cs @@ -3,7 +3,7 @@ using Lagrange.Core.Internal.Packets.Notify; using Lagrange.Core.Utility; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.Event0x210, 138, true)] [MsgPushProcessor(MsgType.Event0x210, 139, true)] diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/FriendRequestProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/FriendRequestProcessor.cs similarity index 93% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/FriendRequestProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/FriendRequestProcessor.cs index 21b46fbe..f78f60ef 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/FriendRequestProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/FriendRequestProcessor.cs @@ -3,7 +3,7 @@ using Lagrange.Core.Internal.Packets.Notify; using Lagrange.Core.Utility; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.Event0x210, 35, true)] // FriendRequestNotice internal class FriendRequestProcessor : MsgPushProcessorBase diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupInviteProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/GroupInviteProcessor.cs similarity index 96% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupInviteProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/GroupInviteProcessor.cs index 1ffda739..6deadd75 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupInviteProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/GroupInviteProcessor.cs @@ -5,7 +5,7 @@ using Lagrange.Core.Internal.Packets.Notify; using Lagrange.Core.Utility; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.Event0x20D, true)] internal class GroupInviteProcessor : MsgPushProcessorBase diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupJoinProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/GroupJoinProcessor.cs similarity index 96% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupJoinProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/GroupJoinProcessor.cs index b828dee1..a2f9325d 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupJoinProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/GroupJoinProcessor.cs @@ -5,7 +5,7 @@ using Lagrange.Core.Internal.Packets.Notify; using Lagrange.Core.Utility; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.GroupJoinNotification, true)] internal class GroupJoinProcessor : MsgPushProcessorBase diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupMemberDecreaseProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/GroupMemberDecreaseProcessor.cs similarity index 97% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupMemberDecreaseProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/GroupMemberDecreaseProcessor.cs index 11c2fe9a..891b6431 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupMemberDecreaseProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/GroupMemberDecreaseProcessor.cs @@ -3,7 +3,7 @@ using Lagrange.Core.Internal.Packets.Notify; using Lagrange.Core.Utility; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.GroupMemberDecreaseNotice, true)] internal class GroupMemberDecreaseProcessor : MsgPushProcessorBase diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupMemberIncreaseProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/GroupMemberIncreaseProcessor.cs similarity index 96% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupMemberIncreaseProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/GroupMemberIncreaseProcessor.cs index 45e4e863..61ebdfb4 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupMemberIncreaseProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/GroupMemberIncreaseProcessor.cs @@ -6,7 +6,7 @@ using Lagrange.Core.Internal.Packets.Notify; using Lagrange.Core.Utility; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.GroupMemberIncreaseNotice, true)] internal class GroupMemberIncreaseProcessor : MsgPushProcessorBase diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupNudgeProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/GroupNudgeProcessor.cs similarity index 96% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupNudgeProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/GroupNudgeProcessor.cs index 7d0094c1..602d2643 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupNudgeProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/GroupNudgeProcessor.cs @@ -4,7 +4,7 @@ using Lagrange.Core.Utility; using Lagrange.Core.Utility.Binary; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.Event0x2DC, 20, true)] // GroupGreyTipNotice20 internal class GroupNudgeProcessor : MsgPushProcessorBase diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupReactionProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/GroupReactionProcessor.cs similarity index 95% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupReactionProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/GroupReactionProcessor.cs index 8f49cc4e..7ba8b68c 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupReactionProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/GroupReactionProcessor.cs @@ -4,7 +4,7 @@ using Lagrange.Core.Utility; using Lagrange.Core.Utility.Binary; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.Event0x2DC, 16, true)] internal class GroupReactionProcessor : MsgPushProcessorBase diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupRecallMessageProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/GroupRecallMessageProcessor.cs similarity index 95% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupRecallMessageProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/GroupRecallMessageProcessor.cs index 7306c2b5..ad0a5405 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/GroupRecallMessageProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/GroupRecallMessageProcessor.cs @@ -4,7 +4,7 @@ using Lagrange.Core.Utility; using Lagrange.Core.Utility.Binary; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.Event0x2DC, 17, true)] internal class GroupRecallMessageProcessor : MsgPushProcessorBase diff --git a/Lagrange.Core/Internal/Logic/MsgPushProccessors/RichTextMsgProcessor.cs b/Lagrange.Core/Internal/Logic/Processors/RichTextMsgProcessor.cs similarity index 97% rename from Lagrange.Core/Internal/Logic/MsgPushProccessors/RichTextMsgProcessor.cs rename to Lagrange.Core/Internal/Logic/Processors/RichTextMsgProcessor.cs index 8d1a08e9..1b940511 100644 --- a/Lagrange.Core/Internal/Logic/MsgPushProccessors/RichTextMsgProcessor.cs +++ b/Lagrange.Core/Internal/Logic/Processors/RichTextMsgProcessor.cs @@ -6,7 +6,7 @@ using Lagrange.Core.Message; using Lagrange.Core.Message.Entities; -namespace Lagrange.Core.Internal.Logic.MsgPushProccessors; +namespace Lagrange.Core.Internal.Logic.Processors; [MsgPushProcessor(MsgType.GroupMessage)] [MsgPushProcessor(MsgType.PrivateMessage)] diff --git a/Lagrange.Milky/Entity/Segment/ForwardSegment.cs b/Lagrange.Milky/Entity/Segment/ForwardSegment.cs index 47413e6c..828da221 100644 --- a/Lagrange.Milky/Entity/Segment/ForwardSegment.cs +++ b/Lagrange.Milky/Entity/Segment/ForwardSegment.cs @@ -12,4 +12,25 @@ public class ForwardIncomingSegmentData(string forwardId) { [JsonPropertyName("forward_id")] public string ForwardId { get; } = forwardId; +} + +public class ForwardOutgoingSegment(ForwardOutgoingSegmentData data) : OutgoingSegmentBase(data) { } + +public class ForwardOutgoingSegmentData(ForwardOutgoingSegmentDataItem[] messages) +{ + [JsonRequired] + [JsonPropertyName("messages")] + public ForwardOutgoingSegmentDataItem[] Messages { get; init; } = messages; +} + +public class ForwardOutgoingSegmentDataItem(long userId, string senderName, IOutgoingSegment[] segments) +{ + [JsonPropertyName("user_id")] + public long UserId { get; init; } = userId; + + [JsonPropertyName("sender_name")] + public string SenderName { get; init; } = senderName; + + [JsonPropertyName("segments")] + public IOutgoingSegment[] Segments { get; init; } = segments; } \ No newline at end of file diff --git a/Lagrange.Milky/Entity/Segment/ISegment.cs b/Lagrange.Milky/Entity/Segment/ISegment.cs index 64b64410..c92bd866 100644 --- a/Lagrange.Milky/Entity/Segment/ISegment.cs +++ b/Lagrange.Milky/Entity/Segment/ISegment.cs @@ -30,7 +30,7 @@ public interface IIncomingSegment [JsonDerivedType(typeof(ImageOutgoingSegment), typeDiscriminator: "image")] [JsonDerivedType(typeof(RecordOutgoingSegment), typeDiscriminator: "record")] [JsonDerivedType(typeof(VideoOutgoingSegment), typeDiscriminator: "video")] -// [JsonDerivedType(typeof(ForwardOutgoingSegment), typeDiscriminator: "forward")] +[JsonDerivedType(typeof(ForwardOutgoingSegment), typeDiscriminator: "forward")] public interface IOutgoingSegment { object? Data { get; } diff --git a/Lagrange.Milky/README.md b/Lagrange.Milky/README.md index 7b739bf1..a5c4cf38 100644 --- a/Lagrange.Milky/README.md +++ b/Lagrange.Milky/README.md @@ -154,7 +154,7 @@ Current Milky version: [77c6cbd](https://github.com/SaltifyDev/milky/tree/77c6cb - [x] image - [x] record - [ ] video -- [ ] forward +- [x] forward #### forward diff --git a/Lagrange.Milky/Utility/EntityConvert.Segment.cs b/Lagrange.Milky/Utility/EntityConvert.Segment.cs index 4319e333..bd26a677 100644 --- a/Lagrange.Milky/Utility/EntityConvert.Segment.cs +++ b/Lagrange.Milky/Utility/EntityConvert.Segment.cs @@ -121,7 +121,7 @@ await _resolver.ToMemoryStreamAsync(video.Data.Uri, token), video.Data.ThumbUri != null ? await _resolver.ToMemoryStreamAsync(video.Data.ThumbUri, token) : null, disposeOnCompletion: true ), - // TODO: ForwardOutgoingSegment + ForwardOutgoingSegment forwardOutgoingSegment => await BuildMultiMsgEntityAsync(forwardOutgoingSegment.Data.Messages, token), _ => throw new NotSupportedException(), }; @@ -141,4 +141,17 @@ private async Task ReplyFriendSegmentAsync(ReplyOutgoingSegment return new ReplyEntity(message); } + + private async Task BuildMultiMsgEntityAsync(IReadOnlyList data, CancellationToken token) + { + var multiMsgEntity = new MultiMsgEntity(); + foreach (var segment in data) + { + var msgChain = await FakeSegmentsAsync(segment.Segments, token); + var msg = BotMessage.CreateCustomFriend(segment.UserId, segment.SenderName, 0, string.Empty, DateTime.Now, msgChain); + multiMsgEntity.Messages.Add(msg); + } + + return multiMsgEntity; + } } \ No newline at end of file