[Core] Implemented LeaveGroup
This commit is contained in:
parent
e0af29a5ce
commit
55560cbd2d
|
@ -47,6 +47,9 @@ public static class GroupExt
|
|||
|
||||
public static Task<bool> RemarkGroup(this BotContext bot, uint groupUin, string targetRemark)
|
||||
=> bot.ContextCollection.Business.OperationLogic.RemarkGroup(groupUin, targetRemark);
|
||||
|
||||
public static Task<bool> LeaveGroup(this BotContext bot, uint groupUin)
|
||||
=> bot.ContextCollection.Business.OperationLogic.LeaveGroup(groupUin);
|
||||
|
||||
#region Group File System
|
||||
|
||||
|
|
|
@ -102,6 +102,12 @@ internal class OperationLogic : LogicBase
|
|||
return events.Count != 0 && ((GroupRemarkEvent)events[0]).ResultCode == 0;
|
||||
}
|
||||
|
||||
public async Task<bool> LeaveGroup(uint groupUin)
|
||||
{
|
||||
var leaveGroupEvent = GroupLeaveEvent.Create(groupUin);
|
||||
var events = await Collection.Business.SendEvent(leaveGroupEvent);
|
||||
return events.Count != 0 && ((GroupLeaveEvent)events[0]).ResultCode == 0;
|
||||
}
|
||||
|
||||
public async Task<ulong> FetchGroupFSSpace(uint groupUin)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
namespace Lagrange.Core.Internal.Event.Protocol.Action;
|
||||
|
||||
internal class GroupLeaveEvent : ProtocolEvent
|
||||
{
|
||||
public uint GroupUin { get; set; }
|
||||
|
||||
private GroupLeaveEvent(uint groupUin) : base(true)
|
||||
{
|
||||
GroupUin = groupUin;
|
||||
}
|
||||
|
||||
private GroupLeaveEvent(int resultCode) : base(resultCode) { }
|
||||
|
||||
public static GroupLeaveEvent Create(uint groupUin) => new(groupUin);
|
||||
|
||||
public static GroupLeaveEvent Result(int resultCode) => new(resultCode);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using ProtoBuf;
|
||||
|
||||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
/// <summary>
|
||||
/// Quit Group
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
[OidbSvcTrpcTcp(0x1097, 1)]
|
||||
internal class OidbSvcTrpcTcp0x1097_1
|
||||
{
|
||||
[ProtoMember(1)] public uint GroupUin { get; set; }
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using Lagrange.Core.Common;
|
||||
using Lagrange.Core.Internal.Event.Protocol;
|
||||
using Lagrange.Core.Internal.Event.Protocol.Action;
|
||||
using Lagrange.Core.Internal.Packets.Service.Oidb;
|
||||
using Lagrange.Core.Internal.Packets.Service.Oidb.Request;
|
||||
using Lagrange.Core.Utility.Binary;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Lagrange.Core.Internal.Service.Action;
|
||||
|
||||
[EventSubscribe(typeof(GroupLeaveEvent))]
|
||||
[Service("OidbSvcTrpcTcp.0x1097_1")]
|
||||
internal class GroupLeaveService : BaseService<GroupLeaveEvent>
|
||||
{
|
||||
protected override bool Build(GroupLeaveEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
|
||||
out BinaryPacket output, out List<BinaryPacket>? extraPackets)
|
||||
{
|
||||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x1097_1>(new OidbSvcTrpcTcp0x1097_1
|
||||
{
|
||||
GroupUin = input.GroupUin
|
||||
});
|
||||
|
||||
var stream = new MemoryStream();
|
||||
Serializer.Serialize(stream, packet);
|
||||
output = new BinaryPacket(stream);
|
||||
|
||||
extraPackets = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool Parse(byte[] input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
|
||||
out GroupLeaveEvent output, out List<ProtocolEvent>? extraEvents)
|
||||
{
|
||||
var payload = Serializer.Deserialize<OidbSvcTrpcTcpResponse<byte[]>>(input.AsSpan());
|
||||
|
||||
output = GroupLeaveEvent.Result((int)payload.ErrorCode);
|
||||
extraEvents = null;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ Please use Lagrange.Core responsibly and in accordance with the law.
|
|||
|----------|---------|---------------------------|---------|:-----------------|:-----------|:------------------|:-----------|:-----------------------|:--------|
|
||||
| Windows | 🟢 | QrCode | 🟢 | Images | 🟢 | ~~Poke~~ | 🔴 | Captcha | 🟢 |
|
||||
| macOS | 🟢 | Password | 🟢 | Text / At | 🟢 | Recall | 🟡 | BotOnline | 🟢 |
|
||||
| Linux | 🟢 | EasyLogin | 🟢 | ~~Records~~ | 🔴 | Leave Group | 🔴 | BotOffline | 🟢 |
|
||||
| Linux | 🟢 | EasyLogin | 🟢 | ~~Records~~ | 🔴 | Leave Group | 🟢 | BotOffline | 🟢 |
|
||||
| | | UnusalDevice<br/>Password | 🔴 | QFace | 🟢 | ~~Special Title~~ | 🔴 | Message | 🟢 |
|
||||
| | | UnusalDevice<br/>Easy | 🟢 | Json | 🟡 | Kick Member | 🟢 | ~~Poke~~ | 🔴 |
|
||||
| | | NewDeviceVerify | 🔴 | Xml | 🟢 | Mute Member | 🟢 | MessageRecall | 🔴 |
|
||||
|
|
Loading…
Reference in New Issue