forked from LagrangeDev/Lagrange.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Lagrange.OneBot/Core/Entity/Message/OneBotGroupMsgHistorySeq.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Lagrange.OneBot.Core.Entity.Message; | ||
|
||
[Serializable] | ||
public class OneBotGroupMsgHistorySeq | ||
{ | ||
[JsonPropertyName("group_id")] public uint GroupId { get; set; } | ||
|
||
[JsonPropertyName("start")] public int Start { get; set; } | ||
|
||
[JsonPropertyName("end")] public int End { get; set; } | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
Lagrange.OneBot/Core/Operation/Message/GetGroupMessageHistorySeqOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
using Lagrange.Core; | ||
using Lagrange.Core.Common.Interface.Api; | ||
using Lagrange.Core.Message; | ||
using Lagrange.OneBot.Core.Entity.Action; | ||
using Lagrange.OneBot.Core.Entity.Message; | ||
using Lagrange.OneBot.Core.Operation.Converters; | ||
using Lagrange.OneBot.Database; | ||
using Lagrange.OneBot.Message; | ||
using LiteDB; | ||
|
||
namespace Lagrange.OneBot.Core.Operation.Message; | ||
|
||
[Operation("get_group_msg_history_seq")] | ||
public class GetGroupMessageHistorySeqOperation(MessageService message) : IOperation | ||
{ | ||
public async Task<OneBotResult> HandleOperation(BotContext context, JsonNode? payload) | ||
{ | ||
if (payload.Deserialize<OneBotGroupMsgHistorySeq>(SerializerOptions.DefaultOptions) is { } history) | ||
{ | ||
if (await context.GetGroupMessage(history.GroupId, (uint)history.Start, (uint)(history.End == 0 ? history.Start : history.End)) is { } results) | ||
{ | ||
var messages = results | ||
.Select(x => message.ConvertToGroupMsg(context.BotUin, x)) | ||
.ToList(); | ||
return new OneBotResult(new OneBotGroupMsgHistoryResponse(messages), 0, "ok"); | ||
} | ||
} | ||
|
||
throw new Exception(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters