Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
RikaCelery committed Jan 20, 2025
1 parent fd5335f commit 2232f9a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 36 deletions.
8 changes: 3 additions & 5 deletions Lagrange.Core/Internal/Event/System/FetchRKeyEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ internal class FetchRKeyEvent : ProtocolEvent
{
public List<RKeyInfo> RKeys { get; } = new();

private FetchRKeyEvent() : base(true)
{
}
private FetchRKeyEvent() : base(true) { }

private FetchRKeyEvent(int resultCode, List<RKeyInfo> rKeys) : base(resultCode)
{
RKeys = rKeys;
}

public static FetchRKeyEvent Create() => new();

public static FetchRKeyEvent Result(int resultCode, List<RKeyInfo> rKeys) => new(resultCode, rKeys);
}
25 changes: 2 additions & 23 deletions Lagrange.Core/Internal/Service/System/FetchRKeyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,14 @@ internal class FetchRKeyService : BaseService<FetchRKeyEvent>
protected override bool Build(FetchRKeyEvent input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
out Span<byte> output, out List<Memory<byte>>? extraPackets)
{
var packet = new OidbSvcTrpcTcpBase<NTV2RichMediaReq>(new NTV2RichMediaReq
{
ReqHead = new MultiMediaReqHead
{
Common = new CommonHead
{
RequestId = 1,
Command = 202
},
Scene = new SceneInfo
{
RequestType = 2,
BusinessType = 1,
SceneType = 0
},
Client = new ClientMeta { AgentType = 2 }
},
DownloadRKey = new DownloadRKeyReq
{
Types = new List<int> { 10, 20, 2 }
}
}, 0x9067, 202, false, true);
var packet = new OidbSvcTrpcTcpBase<NTV2RichMediaReq>(new NTV2RichMediaReq { ReqHead = new MultiMediaReqHead { Common = new CommonHead { RequestId = 1, Command = 202 }, Scene = new SceneInfo { RequestType = 2, BusinessType = 1, SceneType = 0 }, Client = new ClientMeta { AgentType = 2 } }, DownloadRKey = new DownloadRKeyReq { Types = new List<int> { 10, 20, 2 } } }, 0x9067, 202, false, true);

extraPackets = null;
output = packet.Serialize();
return true;
}

protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
protected override bool Parse(Span<byte> input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device,
out FetchRKeyEvent output, out List<ProtocolEvent>? extraEvents)
{
var payload = Serializer.Deserialize<OidbSvcTrpcTcpBase<NTV2RichMediaResp>>(input);
Expand Down
10 changes: 2 additions & 8 deletions Lagrange.OneBot/Core/Operation/Generic/GetRkey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
var fetchRKeyEvent = FetchRKeyEvent.Create();
var events = await context.ContextCollection.Business.SendEvent(fetchRKeyEvent);
var rKeyEvent = (FetchRKeyEvent)events[0];
if (rKeyEvent.ResultCode!=0) return new OneBotResult(null, rKeyEvent.ResultCode, "failed");
var response = new OneBotGetRkeyResponse(rKeyEvent.RKeys.Select(x=>new OneBotRkey
{
Type = x.Type==10?"private":"group",
Rkey = x.Rkey,
CreateTime = x.RkeyCreateTime,
TtlSeconds = x.RkeyTtlSec
}).ToList());
if (rKeyEvent.ResultCode != 0) return new OneBotResult(null, rKeyEvent.ResultCode, "failed");
var response = new OneBotGetRkeyResponse(rKeyEvent.RKeys.Select(x => new OneBotRkey { Type = x.Type == 10 ? "private" : "group", Rkey = x.Rkey, CreateTime = x.RkeyCreateTime, TtlSeconds = x.RkeyTtlSec }).ToList());
return new OneBotResult(response, 0, "ok");
}
}

0 comments on commit 2232f9a

Please sign in to comment.