-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OneBot] Implemented get_group_file_url
- Loading branch information
1 parent
1962454
commit c5e977c
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
Lagrange.OneBot/Core/Entity/Action/Response/OneBotGetFileUrl.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,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; } | ||
} |
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,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(); | ||
} | ||
} |