Skip to content

Commit

Permalink
[Core] Minor change to code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan04 committed Oct 3, 2024
1 parent bfc344d commit 345dffa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal CachingLogic(ContextCollection collection) : base(collection)
_cachedFriends = new List<BotFriend>();
_cachedGroupMembers = new Dictionary<uint, List<BotGroupMember>>();

_cacheUsers = new();
_cacheUsers = new ConcurrentDictionary<uint, BotUserInfo>();
}

public override Task Incoming(ProtocolEvent e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class CustomFace

[ProtoMember(5)] public byte[] Flag { get; set; }

[ProtoMember(6)] public byte[] OldData { get; set; }
[ProtoMember(6)] public byte[]? OldData { get; set; }

[ProtoMember(7)] public uint FileId { get; set; }

Expand Down
11 changes: 2 additions & 9 deletions Lagrange.Core/Message/Entity/ImageEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ IEnumerable<Elem> IMessageEntity.PackElement()

var elems = new Elem[]
{
new(),
new()
{
CommonElem = new CommonElem
Expand All @@ -97,9 +96,7 @@ IEnumerable<Elem> IMessageEntity.PackElement()
if (elems.CommonElem is { ServiceType: 48, BusinessType: 20 or 10 } common)
{
var extra = Serializer.Deserialize<MsgInfo>(common.PbElem.AsSpan());

var msgInfoBody = extra.MsgInfoBody[0];

var index = msgInfoBody.Index;

return new ImageEntity
Expand Down Expand Up @@ -156,7 +153,6 @@ IEnumerable<Elem> IMessageEntity.PackElement()
Summary = face.PbReserve?.Summary,
SubType = face.PbReserve?.SubType ?? GetImageTypeFromFaceOldData(face)
};

}

return new ImageEntity
Expand All @@ -175,11 +171,8 @@ IEnumerable<Elem> IMessageEntity.PackElement()

private static int GetImageTypeFromFaceOldData(CustomFace face)
{
if (face.OldData == null || face.OldData.Length < 5)
{
return 0;
}
// maybe legacy PCQQ(TIM)
if (face.OldData is not { Length: >= 5 }) return 0; // maybe legacy PCQQ(TIM)

return face.OldData[4].ToString("X2") switch
{
"36" => 1,
Expand Down

0 comments on commit 345dffa

Please sign in to comment.