Skip to content

Commit

Permalink
[OneBot] fix check sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkRRb committed Nov 26, 2024
1 parent 5e7072c commit a0c881a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
);
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
var multi = new MultiMsgEntity(chains);
var chain = MessageBuilder.Group(forward.GroupId).Add(multi).Build();
var ret = await context.SendMessage(chain);

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

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

return new OneBotResult(new OneBotForwardResponse(hash, multi.ResId ?? ""), (int)ret.Result, "ok");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
OneBotGroupMessageText messageText => common.ParseChain(messageText).Build(),
_ => throw new Exception()
};

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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
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(result.MessageId, result.Sequence ?? 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
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(result.MessageId, result.Sequence ?? 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? pa
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(result.MessageId, result.Sequence ?? 0);

Expand Down

0 comments on commit a0c881a

Please sign in to comment.