Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
21 changes: 21 additions & 0 deletions Lagrange.Milky/Entity/Segment/ForwardSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,25 @@ public class ForwardIncomingSegmentData(string forwardId)
{
[JsonPropertyName("forward_id")]
public string ForwardId { get; } = forwardId;
}

public class ForwardOutgoingSegment(ForwardOutgoingSegmentData data) : OutgoingSegmentBase<ForwardOutgoingSegmentData>(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;
}
2 changes: 1 addition & 1 deletion Lagrange.Milky/Entity/Segment/ISegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion Lagrange.Milky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Current Milky version: [77c6cbd](https://github.com/SaltifyDev/milky/tree/77c6cb
- [x] image
- [x] record
- [ ] video
- [ ] forward
- [x] forward

#### forward

Expand Down
15 changes: 14 additions & 1 deletion Lagrange.Milky/Utility/EntityConvert.Segment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};

Expand All @@ -141,4 +141,17 @@ private async Task<IMessageEntity> ReplyFriendSegmentAsync(ReplyOutgoingSegment

return new ReplyEntity(message);
}

private async Task<MultiMsgEntity> BuildMultiMsgEntityAsync(IReadOnlyList<ForwardOutgoingSegmentDataItem> 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;
}
}