Skip to content

Commit

Permalink
[OneBot] adjust SendGroupAiRecordOperation (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
pk5ls20 authored Jan 4, 2025
1 parent 91d2975 commit 05d793e
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Lagrange.OneBot.Core.Operation.Message;

[Operation("send_group_ai_record")]
public class GetAiRecordOperation : IOperation
public class SendGroupAiRecordOperation : IOperation
{
public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload)
{
Expand All @@ -24,17 +24,9 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
message.Text,
message.ChatType
);
if (code != 0 || recordEntity == null) return new OneBotResult(null, code, "failed");

var chain = MessageBuilder.Group(message.GroupId).Add(recordEntity).Build();
var result = await context.SendMessage(chain);

if (result.Result != 0) return new OneBotResult(null, (int)result.Result, "failed");
if (result.Sequence == null || result.Sequence == 0) return new OneBotResult(null, 9000, "failed");

int hash = MessageRecord.CalcMessageHash(chain.MessageId, result.Sequence ?? 0);

return new OneBotResult(new OneBotMessageResponse(hash), (int)result.Result, "ok");
return recordEntity != null && code == 0
? new OneBotResult(new OneBotMessageResponse(0), code, "ok")
: new OneBotResult(null, code, "failed");
}

throw new Exception();
Expand Down

0 comments on commit 05d793e

Please sign in to comment.