forked from LagrangeDev/Lagrange.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Lagrange.Core.Internal.Event.Action; | ||
|
||
internal class GroupSetBothdEvent : ProtocolEvent | ||
{ | ||
public uint BotId { get; set; } | ||
|
||
public uint GroupUin { get; set; } | ||
|
||
private GroupSetBothdEvent(uint botId, uint groupuin) : base(0) | ||
{ | ||
BotId = botId; | ||
GroupUin = groupuin; | ||
} | ||
|
||
private GroupSetBothdEvent(int resultCode) : base(resultCode) { } | ||
|
||
public static GroupSetBothdEvent Create(uint botId, uint groupuin) => new(botId, groupuin); | ||
|
||
public static GroupSetBothdEvent Result(int resultCode) => new(resultCode); | ||
} |
25 changes: 25 additions & 0 deletions
25
Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0x112E_1.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,25 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
|
||
// ReSharper disable InconsistentNaming | ||
#pragma warning disable CS8618 | ||
|
||
[ProtoContract] | ||
[OidbSvcTrpcTcp(0x112E, 1)] | ||
internal class OidbSvcTrpcTcp0x112E_1 | ||
{ | ||
[ProtoMember(3)] public uint BotId { get; set; } | ||
|
||
[ProtoMember(4)] public uint Seq { get; set; } = 111111; | ||
|
||
[ProtoMember(5)] public string B_id { get; set; } = ""; | ||
|
||
[ProtoMember(6)] public string B_data { get; set; } = ""; | ||
|
||
[ProtoMember(7)] public uint IDD { get; set; } = 0; | ||
|
||
[ProtoMember(8)] public uint GroupUin { get; set; } | ||
|
||
[ProtoMember(9)] public uint GroupType { get; set; } = 1; | ||
} |
35 changes: 35 additions & 0 deletions
35
Lagrange.Core/Internal/Service/Action/GroupSetBothdService.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,35 @@ | ||
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.Internal.Packets.Service.Oidb.Response; | ||
using Lagrange.Core.Utility.Binary; | ||
using Lagrange.Core.Utility.Extension; | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Service.Action; | ||
|
||
[EventSubscribe(typeof(GroupSetBothdEvent))] | ||
[Service("OidbSvcTrpcTcp.0x112e_1")] | ||
internal class GroupSetBothdService : BaseService<GroupSetBothdEvent> | ||
{ | ||
protected override bool Build(GroupSetBothdEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out BinaryPacket output, out List<BinaryPacket>? extraPackets) | ||
{ | ||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x112E_1>(new OidbSvcTrpcTcp0x112E_1 | ||
{ | ||
BotId = input.BotId, | ||
Seq = 11111, | ||
B_id = "", | ||
B_data = "", | ||
IDD = 0, | ||
GroupUin = input.GroupUin, | ||
GroupType = 1 | ||
}); | ||
output = packet.Serialize(); | ||
extraPackets = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Lagrange.OneBot.Core.Entity.Action; | ||
|
||
[Serializable] | ||
public class OneBotSetGroupBothd | ||
{ | ||
[JsonPropertyName("group_id")] public uint GroupId { get; set; } | ||
|
||
[JsonPropertyName("bot_id")] public uint BotId { get; set; } | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
Lagrange.OneBot/Core/Operation/Group/SetGroupBothdOperation.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,26 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
using Lagrange.Core; | ||
using Lagrange.Core.Common.Interface.Api; | ||
using Lagrange.OneBot.Core.Entity.Action; | ||
using Lagrange.OneBot.Core.Operation.Converters; | ||
|
||
namespace Lagrange.OneBot.Core.Operation.Group; | ||
|
||
[Operation("set_group_bot_hd")] | ||
public class SetGroupBothdOperation : IOperation | ||
{ | ||
public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload) | ||
{ | ||
var message = payload.Deserialize<OneBotSetGroupBothd>(SerializerOptions.DefaultOptions); | ||
|
||
if (message != null) | ||
{ | ||
bool _ = await context.SetGroupBotHD(message.BotId, message.GroupId); | ||
|
||
return new OneBotResult(message.BotId, 0, "ok"); | ||
} | ||
|
||
throw new Exception(); | ||
} | ||
} |