Skip to content

Commit 10bfa74

Browse files
committed
[Core] Fix Sequence exceeds int in certain cases And ReSharper Shut Up
1 parent e69b90c commit 10bfa74

26 files changed

Lines changed: 53 additions & 53 deletions

Lagrange.Core.NativeAPI/NativeModel/Message/Entity/ReplyEntityStruct.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public ReplyEntityStruct() { }
1111

1212
public ulong SrcUid;
1313

14-
public int SrcSequence;
14+
public ulong SrcSequence;
1515

1616
public IntPtr Source;
1717

Lagrange.Core/Common/Interface/MessageExt.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static Task<BotMessage> SendFriendMessage(this BotContext context, long f
1111
public static Task<BotMessage> SendGroupMessage(this BotContext context, long groupUin, MessageChain chain)
1212
=> context.EventContext.GetLogic<MessagingLogic>().SendGroupMessage(groupUin, chain);
1313

14-
public static Task<List<BotMessage>> GetGroupMessage(this BotContext context, long groupUin, int startSequence, int endSequence)
14+
public static Task<List<BotMessage>> GetGroupMessage(this BotContext context, long groupUin, ulong startSequence, ulong endSequence)
1515
=> context.EventContext.GetLogic<MessagingLogic>().GetGroupMessage(groupUin, startSequence, endSequence);
1616

1717
public static Task<List<BotMessage>> GetRoamMessage(this BotContext context, long friendUin, uint timestamp, uint count)
@@ -23,10 +23,10 @@ public static Task<List<BotMessage>> GetRoamMessage(this BotContext context, Bot
2323
return context.EventContext.GetLogic<MessagingLogic>().GetRoamMessage(target.Contact.Uin, timestamp, count);
2424
}
2525

26-
public static Task<List<BotMessage>> GetC2CMessage(this BotContext context, long peerUin, int startSequence, int endSequence)
26+
public static Task<List<BotMessage>> GetC2CMessage(this BotContext context, long peerUin, ulong startSequence, ulong endSequence)
2727
=> context.EventContext.GetLogic<MessagingLogic>().GetC2CMessage(peerUin, startSequence, endSequence);
2828

29-
public static Task<(int Sequence, DateTime Time)> SendFriendFile(this BotContext context, long targetUin, Stream fileStream, string? fileName = null)
29+
public static Task<(ulong Sequence, DateTime Time)> SendFriendFile(this BotContext context, long targetUin, Stream fileStream, string? fileName = null)
3030
=> context.EventContext.GetLogic<OperationLogic>().SendFriendFile(targetUin, fileStream, fileName);
3131

3232
public static Task<string> SendGroupFile(this BotContext context, long groupUin, Stream fileStream, string? fileName = null, string parentDirectory = "/")

Lagrange.Core/Internal/Events/Message/GetC2CMessageEvent.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Lagrange.Core.Internal.Events.Message;
44

5-
internal class GetC2CMessageEventReq(string peerUid, int startSequence, int endSequence) : ProtocolEvent
5+
internal class GetC2CMessageEventReq(string peerUid, ulong startSequence, ulong endSequence) : ProtocolEvent
66
{
77
public string PeerUid { get; } = peerUid;
88

9-
public int StartSequence { get; } = startSequence;
9+
public ulong StartSequence { get; } = startSequence;
1010

11-
public int EndSequence { get; } = endSequence;
11+
public ulong EndSequence { get; } = endSequence;
1212
}
1313

1414
internal class GetC2CMessageEventResp(List<CommonMessage> chains) : ProtocolEvent

Lagrange.Core/Internal/Events/Message/GetGroupMessageEvent.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Lagrange.Core.Internal.Events.Message;
44

5-
internal class GetGroupMessageEventReq(long groupUin, int startSequence, int endSequence) : ProtocolEvent
5+
internal class GetGroupMessageEventReq(long groupUin, ulong startSequence, ulong endSequence) : ProtocolEvent
66
{
77
public long GroupUin { get; } = groupUin;
88

9-
public int StartSequence { get; } = startSequence;
9+
public ulong StartSequence { get; } = startSequence;
1010

11-
public int EndSequence { get; } = endSequence;
11+
public ulong EndSequence { get; } = endSequence;
1212
}
1313

1414
internal class GetGroupMessageEventResp(List<CommonMessage> chains) : ProtocolEvent

Lagrange.Core/Internal/Events/Message/SendMessageEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ internal class SendMessageEventReq(BotMessage message) : ProtocolEvent
99
public BotMessage Message { get; } = message;
1010
}
1111

12-
internal class SendFriendFileEventReq(BotFriend friend, FileUploadEventReq request, FileUploadEventResp response, int clientSequence, uint sequence) : ProtocolEvent
12+
internal class SendFriendFileEventReq(BotFriend friend, FileUploadEventReq request, FileUploadEventResp response, ulong clientSequence, uint sequence) : ProtocolEvent
1313
{
1414
public BotFriend Friend { get; } = friend;
1515

1616
public FileUploadEventReq Request { get; } = request;
1717

1818
public FileUploadEventResp Response { get; } = response;
1919

20-
public int ClientSequence { get; } = clientSequence;
20+
public ulong ClientSequence { get; } = clientSequence;
2121

2222
public uint Sequence { get; } = sequence;
2323
}

Lagrange.Core/Internal/Logic/MessagingLogic.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class MessagingLogic(BotContext context) : ILogic
1414

1515
public Task<CommonMessage> BuildFake(BotMessage msg) => _packer.BuildFake(msg);
1616

17-
public async Task<List<BotMessage>> GetGroupMessage(long groupUin, int startSequence, int endSequence)
17+
public async Task<List<BotMessage>> GetGroupMessage(long groupUin, ulong startSequence, ulong endSequence)
1818
{
1919
var result = await context.EventContext.SendEvent<GetGroupMessageEventResp>(new GetGroupMessageEventReq(groupUin, startSequence, endSequence));
2020
var messages = new List<BotMessage>(result.Chains.Count);
@@ -31,7 +31,7 @@ public async Task<List<BotMessage>> GetRoamMessage(long peerUin, uint time, uint
3131
return messages;
3232
}
3333

34-
public async Task<List<BotMessage>> GetC2CMessage(long peerUin, int startSequence, int endSequence)
34+
public async Task<List<BotMessage>> GetC2CMessage(long peerUin, ulong startSequence, ulong endSequence)
3535
{
3636
string peerUid = context.CacheContext.ResolveCachedUid(peerUin) ?? throw new InvalidTargetException(peerUin);
3737
var result = await context.EventContext.SendEvent<GetC2CMessageEventResp>(new GetC2CMessageEventReq(peerUid, startSequence, endSequence));

Lagrange.Core/Internal/Logic/OperationLogic.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public async Task<string> GroupFSDownload(long groupUin, string fileId)
7070

7171
public async Task GroupFSDelete(long groupUin, string fileId) => await context.EventContext.SendEvent<GroupFSDeleteEventResp>(new GroupFSDeleteEventReq(groupUin, fileId));
7272

73-
public async Task<(int, DateTime)> SendFriendFile(long targetUin, Stream fileStream, string? fileName)
73+
public async Task<(ulong, DateTime)> SendFriendFile(long targetUin, Stream fileStream, string? fileName)
7474
{
7575
fileName = ResolveFileName(fileStream, fileName);
7676

@@ -128,7 +128,7 @@ public async Task<string> GroupFSDownload(long groupUin, string fileId)
128128
if (!success) throw new OperationException(-1, "File upload failed");
129129
}
130130

131-
int sequence = Random.Shared.Next(10000, 99999);
131+
ulong sequence = (ulong)Random.Shared.NextInt64(10000, 99999);
132132
uint random = (uint)Random.Shared.Next();
133133
var sendResult = await context.EventContext.SendEvent<SendMessageEventResp>(new SendFriendFileEventReq(friend, request, result, sequence, random));
134134
if (sendResult.Result != 0) throw new OperationException(sendResult.Result);

Lagrange.Core/Internal/Packets/Message/NTMessageCommon.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal partial class ContentHead
3737

3838
[ProtoMember(10)] public int AutoReply { get; set; }
3939

40-
[ProtoMember(11)] public int ClientSequence { get; set; } // nt_msg_seq
40+
[ProtoMember(11)] public ulong ClientSequence { get; set; } // nt_msg_seq
4141

4242
[ProtoMember(12)] public ulong MsgUid { get; set; }
4343
}

Lagrange.Core/Internal/Packets/Message/NTSendMessage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal partial class PbSendMsgReq
1313

1414
[ProtoMember(3)] public MessageBody MessageBody { get; set; }
1515

16-
[ProtoMember(4)] public int ClientSequence { get; set; }
16+
[ProtoMember(4)] public ulong ClientSequence { get; set; }
1717

1818
[ProtoMember(5)] public uint Random { get; set; }
1919
}

Lagrange.Core/Internal/Packets/Message/SsoGetC2CMsg.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ internal partial class SsoGetC2CMsgReq
1111

1212
[ProtoMember(2)] public string? PeerUid { get; set; }
1313

14-
[ProtoMember(3)] public int StartSequence { get; set; }
14+
[ProtoMember(3)] public ulong StartSequence { get; set; }
1515

16-
[ProtoMember(4)] public int EndSequence { get; set; }
16+
[ProtoMember(4)] public ulong EndSequence { get; set; }
1717
}
1818

1919
[ProtoPackable]
@@ -23,9 +23,9 @@ internal partial class SsoGetC2CMsgRsp
2323

2424
[ProtoMember(2)] public string Message { get; set; }
2525

26-
[ProtoMember(3)] public uint StartSequence { get; set; }
26+
[ProtoMember(3)] public ulong StartSequence { get; set; }
2727

28-
[ProtoMember(4)] public uint EndSequence { get; set; }
28+
[ProtoMember(4)] public ulong EndSequence { get; set; }
2929

3030
[ProtoMember(7)] public List<CommonMessage> Messages { get; set; }
3131
}

0 commit comments

Comments
 (0)