Skip to content

Commit

Permalink
[OneBot] async operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Oct 16, 2023
1 parent af6fc25 commit fbb6c73
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lagrange.OneBot/Core/Operation/OperationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public OperationService(BotContext bot, ILagrangeWebService service)
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
{
Expand Down

0 comments on commit fbb6c73

Please sign in to comment.