Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] fix operator in kick event #704

Merged
merged 1 commit into from
Dec 6, 2024
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
34 changes: 27 additions & 7 deletions Lagrange.Core/Internal/Packets/Message/Notify/GroupChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,36 @@ namespace Lagrange.Core.Internal.Packets.Message.Notify;
internal class GroupChange
{
[ProtoMember(1)] public uint GroupUin { get; set; }

[ProtoMember(2)] public uint Flag { get; set; }

[ProtoMember(3)] public string MemberUid { get; set; }

[ProtoMember(4)] public uint DecreaseType { get; set; } // 131 Kick 130 Exit
[ProtoMember(5)] public string? OperatorUid { get; set; }

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

[ProtoMember(6)] public uint IncreaseType { get; set; }

[ProtoMember(7)] public byte[]? Field7 { get; set; }
}

[ProtoContract]
internal class OperatorInfo
{
[ProtoMember(1)] public OperatorField1 Operator { get; set; }
}

[ProtoContract]
internal class OperatorField1
{
[ProtoMember(1)] public string? Uid { get; set; }

[ProtoMember(2)] public uint Field2 { get; set; }

[ProtoMember(3)] public byte[]? Field3 { get; set; }

[ProtoMember(4)] public uint Field4 { get; set; }

[ProtoMember(5)] public byte[]? Field5 { get; set; }
}
14 changes: 12 additions & 2 deletions Lagrange.Core/Internal/Service/Message/PushMessageService.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Text;
using Lagrange.Core.Common;
using Lagrange.Core.Internal.Event;
using Lagrange.Core.Internal.Event.Message;
Expand Down Expand Up @@ -88,14 +89,23 @@ protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo
case PkgType.GroupMemberIncreaseNotice when message.Message.Body?.MsgContent is { } content:
{
var increase = Serializer.Deserialize<GroupChange>(content.AsSpan());
var increaseEvent = GroupSysIncreaseEvent.Result(increase.GroupUin, increase.MemberUid, increase.OperatorUid, increase.DecreaseType);
var increaseEvent = GroupSysIncreaseEvent.Result(increase.GroupUin, increase.MemberUid, Encoding.UTF8.GetString(increase.Operator.AsSpan()), increase.DecreaseType);
extraEvents.Add(increaseEvent);
break;
}
case PkgType.GroupMemberDecreaseNotice when message.Message.Body?.MsgContent is { } content:
{
var decrease = Serializer.Deserialize<GroupChange>(content.AsSpan());
var decreaseEvent = GroupSysDecreaseEvent.Result(decrease.GroupUin, decrease.MemberUid, decrease.OperatorUid, decrease.DecreaseType);
GroupSysDecreaseEvent decreaseEvent;
if (decrease.DecreaseType == 3) // 3 是bot自身被踢出,Operator字段会是一个protobuf
{
var op = Serializer.Deserialize<OperatorInfo>(decrease.Operator.AsSpan());
decreaseEvent = GroupSysDecreaseEvent.Result(decrease.GroupUin, decrease.MemberUid, op.Operator.Uid, decrease.DecreaseType);
}
else
{
decreaseEvent = GroupSysDecreaseEvent.Result(decrease.GroupUin, decrease.MemberUid, Encoding.UTF8.GetString(decrease.Operator.AsSpan()), decrease.DecreaseType);
}
extraEvents.Add(decreaseEvent);
break;
}
Expand Down
Loading