Skip to content

Commit fbb6c73

Browse files
LinwenxuanLinwenxuan
authored andcommitted
[OneBot] async operation
1 parent af6fc25 commit fbb6c73

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Lagrange.OneBot/Core/Operation/OperationService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ public OperationService(BotContext bot, ILagrangeWebService service)
2525
if (attribute != null) _operations[attribute.Api] = (IOperation)type.CreateInstance(false);
2626
}
2727

28-
service.OnMessageReceived += HandleOperation;
28+
service.OnMessageReceived += async (_, s) => await HandleOperation(s);
2929
}
3030

31-
private void HandleOperation(object? sender, string data)
31+
private async Task HandleOperation(string data)
3232
{
3333
var action = JsonSerializer.Deserialize<OneBotAction>(data);
3434

3535
if (action != null)
3636
{
3737
var handler = _operations[action.Action];
38-
var result = handler.HandleOperation(action.Echo, _bot, action.Params);
39-
_service.SendJsonAsync(result);
38+
var result = await handler.HandleOperation(action.Echo, _bot, action.Params);
39+
await _service.SendJsonAsync(result);
4040
}
4141
else
4242
{

0 commit comments

Comments
 (0)