Skip to content

Commit

Permalink
[OneBot] Implemented get_group_file_url
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan04 committed Mar 4, 2024
1 parent 1962454 commit c5e977c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Lagrange.OneBot/Core/Entity/Action/Response/OneBotGetFileUrl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;

namespace Lagrange.OneBot.Core.Entity.Action.Response;

[Serializable]
public class OneBotGetFileUrl
{
[JsonPropertyName("group_id")] public uint GroupId { get; set; }

[JsonPropertyName("file_id")] public string FileId { get; set; } = string.Empty;

[JsonPropertyName("busid")] public uint BusId { get; set; }
}
23 changes: 23 additions & 0 deletions Lagrange.OneBot/Core/Operation/Group/GroupFSOperations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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.Entity.Action.Response;

namespace Lagrange.OneBot.Core.Operation.Group;

[Operation("get_group_file_url")]
public class GetGroupFileUrlOperation : IOperation
{
public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload)
{
if (payload.Deserialize<OneBotGetFileUrl>() is { } url)
{
string raw = await context.FetchGroupFSDownload(url.GroupId, url.FileId);
return new OneBotResult(raw, 0, "ok");
}

throw new Exception();
}
}

0 comments on commit c5e977c

Please sign in to comment.