diff --git a/Lagrange.OneBot/Core/Operation/Message/SendMessageOperation.cs b/Lagrange.OneBot/Core/Operation/Message/SendMessageOperation.cs index 7d69f5f59..aa79eccfc 100644 --- a/Lagrange.OneBot/Core/Operation/Message/SendMessageOperation.cs +++ b/Lagrange.OneBot/Core/Operation/Message/SendMessageOperation.cs @@ -50,6 +50,6 @@ public async Task HandleOperation(BotContext context, JsonNode? pa TargetUin = chain.FriendUin }); - return new OneBotResult(new OneBotMessageResponse(hash), 0, "ok"); + return new OneBotResult(new OneBotMessageResponse(hash,(int)result.Sequence.GetValueOrDefault()), 0, "ok"); } } diff --git a/Lagrange.OneBot/Core/Operation/Message/SendMessageWithGroupSeqOperation.cs b/Lagrange.OneBot/Core/Operation/Message/SendMessageWithGroupSeqOperation.cs index 2e4cadd35..6e5341467 100644 --- a/Lagrange.OneBot/Core/Operation/Message/SendMessageWithGroupSeqOperation.cs +++ b/Lagrange.OneBot/Core/Operation/Message/SendMessageWithGroupSeqOperation.cs @@ -7,11 +7,12 @@ using Lagrange.OneBot.Core.Entity.Message; using Lagrange.OneBot.Core.Operation.Converters; using Lagrange.OneBot.Message; - +using Lagrange.OneBot.Database; +using Lagrange.OneBot.Core.Entity.Action.Response; namespace Lagrange.OneBot.Core.Operation.Message; [Operation("send_msg_with_group_seq")] -public class SendMessageWithGroupSeqOperation(MessageService message) : IOperation +public class SendMessageWithGroupSeqOperation() : IOperation { public async Task HandleOperation(BotContext context, JsonNode? payload) { @@ -21,10 +22,13 @@ public async Task HandleOperation(BotContext context, JsonNode? pa { var newMessageChain = new MessageChain(history.TargetGroupId); var sendMsgRes = await context.SendMessage(newMessageChain, results.Item2?[0] ?? throw new Exception("No PushMsgBody found")); - return new OneBotResult("www", (int)sendMsgRes.Result, "ok"); + + if (sendMsgRes.Result != 0) return new OneBotResult(null, (int)sendMsgRes.Result, "failed"); + if (sendMsgRes.Sequence == null || sendMsgRes.Sequence == 0) return new OneBotResult(null, 9000, "failed"); + int hash = MessageRecord.CalcMessageHash(newMessageChain.MessageId, sendMsgRes.Sequence ?? 0); + return new OneBotResult(new OneBotMessageResponse(hash, (int)sendMsgRes.Sequence.GetValueOrDefault()), (int)sendMsgRes.Result, "ok"); } } - throw new Exception(); } } \ No newline at end of file