submodule对gitea不管用,所以直接拉了一份拉格兰
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Lagrange.Core;
|
||||
using Lagrange.OneBot.Core.Entity.Action;
|
||||
|
||||
namespace Lagrange.OneBot.Core.Operation.Ability;
|
||||
|
||||
[Operation("can_send_image")]
|
||||
public class CanSendImage : IOperation
|
||||
{
|
||||
public Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload) =>
|
||||
Task.FromResult(new OneBotResult(new JsonObject { { "yes", Constant.CanSendImage } }, 0, "ok"));
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Lagrange.Core;
|
||||
using Lagrange.OneBot.Core.Entity.Action;
|
||||
|
||||
namespace Lagrange.OneBot.Core.Operation.Ability;
|
||||
|
||||
[Operation("can_send_record")]
|
||||
public class CanSendRecord : IOperation
|
||||
{
|
||||
public Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload) =>
|
||||
Task.FromResult(new OneBotResult(new JsonObject { { "yes", Constant.CanSendRecord } }, 0, "ok"));
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Lagrange.Core;
|
||||
using Lagrange.Core.Common.Interface.Api;
|
||||
using Lagrange.Core.Message.Entity;
|
||||
using Lagrange.OneBot.Core.Entity.Action;
|
||||
using Lagrange.OneBot.Message.Entity;
|
||||
|
||||
namespace Lagrange.OneBot.Core.Operation.Ability;
|
||||
|
||||
[Operation("upload_image")]
|
||||
public class UploadImageOperation : IOperation
|
||||
{
|
||||
public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload)
|
||||
{
|
||||
if (payload?["file"]?.ToString() is { } file && CommonResolver.ResolveStream(file) is { } stream)
|
||||
{
|
||||
var entity = new ImageEntity(stream);
|
||||
var url = await context.UploadImage(entity);
|
||||
return new OneBotResult(url, 0, "ok");
|
||||
}
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user