-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Core] impl 0x88D_0 * Clean up `using`
- Loading branch information
Showing
18 changed files
with
296 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace Lagrange.Core.Common.Entity; | ||
|
||
public class BotGroupInfo | ||
{ | ||
public string OwnerUid { get; set; } = string.Empty; | ||
|
||
public ulong CreateTime { get; set; } | ||
|
||
public ulong MaxMemberCount { get; set; } | ||
|
||
public ulong MemberCount { get; set; } | ||
|
||
public ulong Level { get; set; } | ||
|
||
public string Name { get; set; } = string.Empty; | ||
|
||
public string NoticePreview { get; set; } = string.Empty; | ||
|
||
public ulong Uin { get; set; } | ||
|
||
public ulong LastSequence { get; set; } | ||
|
||
public ulong LastMessageTime { get; set; } | ||
|
||
public string Question { get; set; } = string.Empty; | ||
|
||
public string Answer { get; set; } = string.Empty; | ||
|
||
public ulong MaxAdminCount { get; set; } | ||
} |
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
31 changes: 31 additions & 0 deletions
31
Lagrange.Core/Internal/Event/Message/GetLatestGroupMessageEvent.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,31 @@ | ||
using Lagrange.Core.Common.Entity; | ||
|
||
namespace Lagrange.Core.Internal.Event.Message; | ||
|
||
internal class GetGroupInfoEvent : ProtocolEvent | ||
{ | ||
public ulong Uin { get; } | ||
|
||
public string? Message { get; } | ||
|
||
public BotGroupInfo Info { get; } | ||
|
||
protected GetGroupInfoEvent(ulong uin) : base(true) | ||
{ | ||
Uin = uin; | ||
Info = new(); | ||
} | ||
|
||
protected GetGroupInfoEvent(int code, string? message, BotGroupInfo info) : base(code) | ||
{ | ||
Message = message; | ||
Info = info; | ||
} | ||
|
||
public static GetGroupInfoEvent Create(ulong uin) => new(uin); | ||
|
||
public static GetGroupInfoEvent Result(int code, string? message, BotGroupInfo info) | ||
{ | ||
return new(code, message, info); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
Lagrange.Core/Internal/Packets/Service/Oidb/Request/OidbSvcTrpcTcp0x88D_0.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,73 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
|
||
#pragma warning disable CS8618 | ||
// ReSharper disable InconsistentNaming | ||
|
||
/// <summary> | ||
/// Get Cookie | ||
/// </summary> | ||
[ProtoContract] | ||
[OidbSvcTrpcTcp(0x88D, 0)] | ||
internal class OidbSvcTrpcTcp0x88D_0 | ||
{ | ||
[ProtoMember(1)] | ||
public uint Field1 { get; set; } | ||
|
||
[ProtoMember(2)] | ||
public OidbSvcTrpcTcp0x88D_0Config Config { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTcp0x88D_0Config | ||
{ | ||
[ProtoMember(1)] | ||
public ulong Uin { get; set; } | ||
|
||
[ProtoMember(2)] | ||
public OidbSvcTrpcTcp0x88D_0Flags Flags { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTcp0x88D_0Flags | ||
{ | ||
[ProtoMember(1)] | ||
public bool? OwnerUid { get; set; } | ||
|
||
[ProtoMember(2)] | ||
public bool? CreateTime { get; set; } | ||
|
||
[ProtoMember(5)] | ||
public bool? MaxMemberCount { get; set; } | ||
|
||
[ProtoMember(6)] | ||
public bool? MemberCount { get; set; } | ||
|
||
[ProtoMember(10)] | ||
public bool? Level { get; set; } | ||
|
||
[ProtoMember(15)] | ||
public string? Name { get; set; } | ||
|
||
[ProtoMember(16)] | ||
public string? NoticePreview { get; set; } | ||
|
||
[ProtoMember(21)] | ||
public bool? Uin { get; set; } | ||
|
||
[ProtoMember(22)] | ||
public bool? LastSequence { get; set; } | ||
|
||
[ProtoMember(23)] | ||
public bool? LastMessageTime { get; set; } | ||
|
||
[ProtoMember(24)] | ||
public bool? Question { get; set; } | ||
|
||
[ProtoMember(25)] | ||
public string? Answer { get; set; } | ||
|
||
[ProtoMember(29)] | ||
public string? MaxAdminCount { get; set; } | ||
} |
66 changes: 66 additions & 0 deletions
66
Lagrange.Core/Internal/Packets/Service/Oidb/Response/OidbSvcTrpcTcp0x88D_0Response.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,66 @@ | ||
using ProtoBuf; | ||
|
||
namespace Lagrange.Core.Internal.Packets.Service.Oidb.Request; | ||
|
||
#pragma warning disable CS8618 | ||
// ReSharper disable InconsistentNaming | ||
|
||
[ProtoContract] | ||
internal class OidbSvcTrpcTcp0x88D_0Response | ||
{ | ||
[ProtoMember(1)] | ||
public OidbSvcTrpcTcp0x88D_0ResponseGroupInfo GroupInfo { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
public class OidbSvcTrpcTcp0x88D_0ResponseGroupInfo | ||
{ | ||
[ProtoMember(1)] | ||
public ulong Uin { get; set; } | ||
|
||
[ProtoMember(2)] | ||
public OidbSvcTrpcTcp0x88D_0ResponseResults Results { get; set; } | ||
} | ||
|
||
[ProtoContract] | ||
public class OidbSvcTrpcTcp0x88D_0ResponseResults | ||
{ | ||
[ProtoMember(1)] | ||
public string OwnerUid { get; set; } | ||
|
||
[ProtoMember(2)] | ||
public ulong CreateTime { get; set; } | ||
|
||
[ProtoMember(5)] | ||
public ulong MaxMemberCount { get; set; } | ||
|
||
[ProtoMember(6)] | ||
public ulong MemberCount { get; set; } | ||
|
||
[ProtoMember(10)] | ||
public ulong Level { get; set; } | ||
|
||
[ProtoMember(15)] | ||
public string Name { get; set; } | ||
|
||
[ProtoMember(16)] | ||
public string NoticePreview { get; set; } | ||
|
||
[ProtoMember(21)] | ||
public ulong Uin { get; set; } | ||
|
||
[ProtoMember(22)] | ||
public ulong LastSequence { get; set; } | ||
|
||
[ProtoMember(23)] | ||
public ulong LastMessageTime { get; set; } | ||
|
||
[ProtoMember(24)] | ||
public string Question { get; set; } | ||
|
||
[ProtoMember(25)] | ||
public string Answer { get; set; } | ||
|
||
[ProtoMember(29)] | ||
public ulong MaxAdminCount { get; set; } | ||
} |
80 changes: 80 additions & 0 deletions
80
Lagrange.Core/Internal/Service/Message/GetLatestGroupMessageService.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,80 @@ | ||
using Lagrange.Core.Common; | ||
using Lagrange.Core.Common.Entity; | ||
using Lagrange.Core.Internal.Event; | ||
using Lagrange.Core.Internal.Event.Message; | ||
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.Message; | ||
|
||
[EventSubscribe(typeof(GetGroupInfoEvent))] | ||
[Service("OidbSvcTrpcTcp.0x88d_0")] | ||
internal class GetGroupInfoService : BaseService<GetGroupInfoEvent> | ||
{ | ||
protected override bool Build(GetGroupInfoEvent input, BotKeystore keystore, BotAppInfo appInfo, | ||
BotDeviceInfo device, out Span<byte> output, out List<Memory<byte>>? extraPackets) | ||
{ | ||
var packet = new OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x88D_0>(new OidbSvcTrpcTcp0x88D_0 | ||
{ | ||
Field1 = 537099973, | ||
Config = new OidbSvcTrpcTcp0x88D_0Config | ||
{ | ||
Uin = input.Uin, | ||
Flags = new OidbSvcTrpcTcp0x88D_0Flags | ||
{ | ||
OwnerUid = true, | ||
CreateTime = true, | ||
MaxMemberCount = true, | ||
MemberCount = true, | ||
Level = true, | ||
Name = "", | ||
NoticePreview = "", | ||
Uin = true, | ||
LastSequence = true, | ||
LastMessageTime = true, | ||
Question = true, | ||
Answer = "", | ||
MaxAdminCount = "", | ||
} | ||
} | ||
}); | ||
|
||
output = packet.Serialize(); | ||
extraPackets = null; | ||
return true; | ||
} | ||
|
||
protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, | ||
out GetGroupInfoEvent output, out List<ProtocolEvent>? extraEvents) | ||
{ | ||
var payload = Serializer.Deserialize<OidbSvcTrpcTcpBase<OidbSvcTrpcTcp0x88D_0Response>>(input); | ||
|
||
if (payload.ErrorCode == 0) | ||
{ | ||
output = GetGroupInfoEvent.Result(0, null, new BotGroupInfo | ||
{ | ||
OwnerUid = payload.Body.GroupInfo.Results.OwnerUid, | ||
CreateTime = payload.Body.GroupInfo.Results.CreateTime, | ||
MaxMemberCount = payload.Body.GroupInfo.Results.MaxMemberCount, | ||
MemberCount = payload.Body.GroupInfo.Results.MemberCount, | ||
Level = payload.Body.GroupInfo.Results.Level, | ||
Name = payload.Body.GroupInfo.Results.Name, | ||
NoticePreview = payload.Body.GroupInfo.Results.NoticePreview, | ||
Uin = payload.Body.GroupInfo.Results.Uin, | ||
LastSequence = payload.Body.GroupInfo.Results.LastSequence, | ||
LastMessageTime = payload.Body.GroupInfo.Results.LastMessageTime, | ||
Question = payload.Body.GroupInfo.Results.Question, | ||
Answer = payload.Body.GroupInfo.Results.Answer, | ||
MaxAdminCount = payload.Body.GroupInfo.Results.MaxAdminCount, | ||
}); | ||
} | ||
else | ||
{ | ||
output = GetGroupInfoEvent.Result((int)payload.ErrorCode, payload.ErrorMsg, new()); | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System.Text.Json.Serialization; | ||
using Lagrange.Core.Common.Entity; | ||
|
||
namespace Lagrange.OneBot.Core.Entity; | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System.Text.Json.Serialization; | ||
using Lagrange.Core.Common.Entity; | ||
|
||
namespace Lagrange.OneBot.Core.Entity; | ||
|
||
|
Oops, something went wrong.