Skip to content

Commit

Permalink
Merge branch 'LagrangeDev:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Shua-github authored Jan 5, 2025
2 parents a4cf3d4 + 05d793e commit 2785229
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 2785229

Please sign in to comment.