-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[All] feat: implemented
get_private_file_url
(#703)
* [All] feat: implemented `get_private_file_url` Signed-off-by: ishkong <[email protected]> * Uniform variable name styles Signed-off-by: ishkong <[email protected]> * 这玩意儿居然不是必须的? Signed-off-by: ishkong <[email protected]> --------- Signed-off-by: ishkong <[email protected]>
- Loading branch information
Showing
6 changed files
with
68 additions
and
3 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
13 changes: 13 additions & 0 deletions
13
Lagrange.OneBot/Core/Entity/Action/OneBotGetPrivateFile.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; | ||
|
||
[Serializable] | ||
public class OneBotGetPrivateFile | ||
{ | ||
[JsonPropertyName("user_id")] public uint UserId { get; set; } | ||
|
||
[JsonPropertyName("file_hash")] public string FileHash { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("file_id")] public required string FileId { 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
23 changes: 23 additions & 0 deletions
23
Lagrange.OneBot/Core/Operation/File/PrivateFSOperations.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,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.Operation.Converters; | ||
|
||
namespace Lagrange.OneBot.Core.Operation.File; | ||
|
||
[Operation("get_private_file_url")] | ||
public class GetPrivateFileUrlOperation : IOperation | ||
{ | ||
public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload) | ||
{ | ||
if (payload.Deserialize<OneBotGetPrivateFile>(SerializerOptions.DefaultOptions) is { } url) | ||
{ | ||
string raw = await context.FetchPrivateFSDownload(url.FileId, url.FileHash, url.UserId); | ||
return new OneBotResult(new JsonObject { { "url", raw } }, 0, "ok"); | ||
} | ||
|
||
throw new Exception(); | ||
} | ||
} |