Skip to content

Commit

Permalink
Fixed Oidb Definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Oct 11, 2023
1 parent bb15c70 commit 8d369ac
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,12 @@ public Task<List<BotGroup>> GetCachedGroups()
return _uinToUid.TryGetValue(friendUin, out var uid) ? uid : null;
}

public async Task<uint?> ResolveUin(uint? groupUin, string friendUid)
public async Task<uint?> ResolveUin(uint? groupUin, string friendUid, bool force = false)
{
if (_uinToUid.Count == 0) await ResolveFriendsUid();
if (groupUin == null) return _uinToUid.FirstOrDefault(x => x.Value == friendUid).Key;

await CacheUid(groupUin.Value);

return _uinToUid.FirstOrDefault(x => x.Value == friendUid).Key;
}

public async Task<uint?> ForceResolveUint(uint? groupUin, string friendUid)
{
if (_uinToUid.Count == 0) await ResolveFriendsUid();
if (groupUin == null) return _uinToUid.FirstOrDefault(x => x.Value == friendUid).Key;

await CacheUid(groupUin.Value, true);
await CacheUid(groupUin.Value, force);

return _uinToUid.FirstOrDefault(x => x.Value == friendUid).Key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override async Task Incoming(ProtocolEvent e)
}
case GroupSysIncreaseEvent increase:
{
uint memberUin = await Collection.Business.CachingLogic.ForceResolveUint(increase.GroupUin, increase.MemberUid) ?? 0;
uint memberUin = await Collection.Business.CachingLogic.ResolveUin(increase.GroupUin, increase.MemberUid, true) ?? 0;
uint? invitorUin = null;
if (increase.InvitorUid != null) invitorUin = await Collection.Business.CachingLogic.ResolveUin(increase.GroupUin, increase.InvitorUid);
var increaseArgs = new GroupMemberIncreaseEvent(increase.GroupUin, memberUin, invitorUin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal class OidbSvcTrpcTcp0xFE7_2Member
[ProtoContract]
internal class OidbSvcTrpcTcp0xFE7_2Uin
{
[ProtoMember(1)] public string Uid { get; set; }
[ProtoMember(2)] public string Uid { get; set; }

[ProtoMember(4)] public uint Uin { get; set; }
}
Expand Down
2 changes: 2 additions & 0 deletions Lagrange.Core/Internal/Service/System/FetchMembersService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Lagrange.Core.Internal.Packets.Service.Oidb.Response;
using Lagrange.Core.Internal.Service.Abstraction;
using Lagrange.Core.Utility.Binary;
using Lagrange.Core.Utility.Extension;
using ProtoBuf;

namespace Lagrange.Core.Internal.Service.System;
Expand Down Expand Up @@ -48,6 +49,7 @@ protected override bool Parse(SsoPacket input, BotKeystore keystore, BotAppInfo
out FetchMembersEvent output, out List<ProtocolEvent>? extraEvents)
{
var payload = input.Payload.ReadBytes(BinaryPacket.Prefix.Uint32 | BinaryPacket.Prefix.WithPrefix);
Console.WriteLine(payload.Hex());
var response = Serializer.Deserialize<OidbSvcTrpcTcpResponse<OidbSvcTrpcTcp0xFE7_2Response>>(payload.AsSpan());

var members = response.Body.Members.Select(member =>
Expand Down

0 comments on commit 8d369ac

Please sign in to comment.