-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[All] Support refuse reason & handle filtered request in GroupRequest (…
- Loading branch information
Showing
14 changed files
with
124 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Lagrange.Core/Internal/Event/Action/SetGroupFilteredRequestEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace Lagrange.Core.Internal.Event.Action; | ||
|
||
internal class SetGroupFilteredRequestEvent : ProtocolEvent | ||
{ | ||
public ulong Sequence { get; set; } | ||
|
||
public uint GroupUin { get; set; } | ||
|
||
public bool Accept { get; set; } | ||
|
||
public uint Type { get; } | ||
|
||
public string Reason { get; set; } = string.Empty; | ||
|
||
private SetGroupFilteredRequestEvent(bool accept, uint groupUin, ulong sequence, uint type, string? reason) : base(true) | ||
{ | ||
Accept = accept; | ||
GroupUin = groupUin; | ||
Sequence = sequence; | ||
Type = type; | ||
Reason = reason ?? ""; | ||
} | ||
|
||
private SetGroupFilteredRequestEvent(int resultCode) : base(resultCode) { } | ||
|
||
public static SetGroupFilteredRequestEvent Create(bool accept, uint groupUin, ulong sequence, uint type, string? reason) | ||
=> new(accept, groupUin, sequence, type, reason); | ||
|
||
public static SetGroupFilteredRequestEvent Result(int resultCode) => new(resultCode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
Lagrange.Core/Internal/Service/Action/SetGroupFilteredRequestService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Lagrange.Core.Common; | ||
using Lagrange.Core.Internal.Event; | ||
using Lagrange.Core.Internal.Event.Action; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb; | ||
using Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
using Lagrange.Core.Utility.Extension; | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Service.Action; | ||
|
||
[EventSubscribe(typeof(SetGroupFilteredRequestEvent))] | ||
[Service("OidbSvcTrpcTcp.0x10c8_2")] | ||
internal class SetGroupFilteredRequestService : BaseService<SetGroupFilteredRequestEvent> | ||
{ | ||
protected override bool Build(SetGroupFilteredRequestEvent input, BotKeystore keystore, BotAppInfo appInfo, | ||
BotDeviceInfo device, out Span<byte> output, out List<Memory<byte>>? extraPackets) | ||
{ | ||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x10C8>(new OidbSvcTrpcTcp0x10C8 | ||
{ | ||
Accept = Convert.ToUInt32(!input.Accept) + 1, | ||
Body = new OidbSvcTrpcTcp0x10C8Body | ||
{ | ||
Sequence = input.Sequence, | ||
EventType = input.Type, | ||
GroupUin = input.GroupUin, | ||
Message = input.Reason | ||
} | ||
}, 0x10c8, 2, false, true); | ||
|
||
output = packet.Serialize(); | ||
extraPackets = null; | ||
return true; | ||
} | ||
|
||
protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out SetGroupFilteredRequestEvent output, out List<ProtocolEvent>? extraEvents) | ||
{ | ||
var payload = Serializer.Deserialize<OidbSvcTrpcTcpBase<byte[]>>(input); | ||
|
||
output = SetGroupFilteredRequestEvent.Result((int)payload.ErrorCode); | ||
extraEvents = null; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters