Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Fix GroupLeave
Browse files Browse the repository at this point in the history
  • Loading branch information
takayama-lily committed Apr 8, 2022
1 parent 17ccebc commit e227e9c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
6 changes: 1 addition & 5 deletions Konata.Core/Components/Logics/Model/OperationLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,8 @@ public async Task<bool> GroupSetSpecialTitle(uint groupUin,
/// <exception cref="OperationFailedException"></exception>
public async Task<bool> GroupLeave(uint groupUin)
{
// Get group code
var groupCode = ConfigComponent.GetGroupCode(groupUin);
if (groupCode == 0) throw new OperationFailedException(-1, "Failed to lave group: Lack group code.");

// Leave group
var args = GroupLeaveEvent.Create(groupCode, Context.Bot.Uin, false);
var args = GroupLeaveEvent.Create(groupUin, Context.Bot.Uin, false);
var result = await Context.SendPacket<GroupLeaveEvent>(args);
{
if (result.ResultCode != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override bool Parse(SSOFrame input,
protected override bool Build(int sequence, GroupLeaveEvent input,
BotKeyStore keystore, BotDevice device, ref PacketBase output)
{
output = new SvcReqGroupMngReq(input.SelfUin, input.GroupCode, input.Dismiss);
output = new SvcReqGroupMngReq(input.SelfUin, input.GroupUin, input.Dismiss);
return true;
}
}
14 changes: 7 additions & 7 deletions Konata.Core/Events/Model/GroupLeaveEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ internal class GroupLeaveEvent : ProtocolEvent
public bool Dismiss { get; }

/// <summary>
/// Group code
/// Group uin
/// </summary>
public ulong GroupCode { get; }
public uint GroupUin { get; }

/// <summary>
/// Self uin
/// </summary>
public uint SelfUin { get; }

private GroupLeaveEvent(ulong groupCode,
private GroupLeaveEvent(uint groupUin,
uint selfUin, bool dismiss) : base(true)
{
GroupCode = groupCode;
GroupUin = groupUin;
SelfUin = selfUin;
Dismiss = dismiss;
}
Expand All @@ -36,12 +36,12 @@ private GroupLeaveEvent(int resultCode)
/// <summary>
/// Construct request event
/// </summary>
/// <param name="groupCode"></param>
/// <param name="groupUin"></param>
/// <param name="selfUin"></param>
/// <param name="dismiss"></param>
/// <returns></returns>
public static GroupLeaveEvent Create(ulong groupCode,
uint selfUin, bool dismiss) => new(groupCode, selfUin, dismiss);
public static GroupLeaveEvent Create(uint groupUin,
uint selfUin, bool dismiss) => new(groupUin, selfUin, dismiss);

/// <summary>
/// Construct event result
Expand Down
6 changes: 3 additions & 3 deletions Konata.Core/Packets/SvcRequest/SvcReqGroupMngReq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Konata.Core.Packets.SvcRequest;

internal class SvcReqGroupMngReq : UniPacket
{
public SvcReqGroupMngReq(uint selfUin, ulong groupCode, bool dismiss)
public SvcReqGroupMngReq(uint selfUin, uint groupUin, bool dismiss)
: base(0x03, "KQQ.ProfileService.ProfileServantObj",
"GroupMngReq", "GroupMngReq", 0x00, 0x00, 117456266,
(out JStruct w) =>
Expand All @@ -22,14 +22,14 @@ public SvcReqGroupMngReq(uint selfUin, ulong groupCode, bool dismiss)
{
if (dismiss)
{
buf.PutUintBE((uint) groupCode);
buf.PutUintBE(groupUin);
buf.PutUintBE(selfUin);
}

else
{
buf.PutUintBE(selfUin);
buf.PutUintBE((uint) groupCode);
buf.PutUintBE(groupUin);
}
}

Expand Down

0 comments on commit e227e9c

Please sign in to comment.