[OneBot] async operation

This commit is contained in:
Linwenxuan 2023-10-16 21:55:22 +08:00
parent af6fc2586e
commit fbb6c73270
1 changed files with 4 additions and 4 deletions

View File

@ -25,18 +25,18 @@ public sealed class OperationService
if (attribute != null) _operations[attribute.Api] = (IOperation)type.CreateInstance(false);
}
service.OnMessageReceived += HandleOperation;
service.OnMessageReceived += async (_, s) => await HandleOperation(s);
}
private void HandleOperation(object? sender, string data)
private async Task HandleOperation(string data)
{
var action = JsonSerializer.Deserialize<OneBotAction>(data);
if (action != null)
{
var handler = _operations[action.Action];
var result = handler.HandleOperation(action.Echo, _bot, action.Params);
_service.SendJsonAsync(result);
var result = await handler.HandleOperation(action.Echo, _bot, action.Params);
await _service.SendJsonAsync(result);
}
else
{