Implemented GroupInfo for Lagrange.OneBot
This commit is contained in:
parent
3e1fefabec
commit
20c633eed6
|
@ -0,0 +1,11 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Lagrange.OneBot.Core.Entity.Action;
|
||||
|
||||
[Serializable]
|
||||
public class OneBotGetGroupInfo
|
||||
{
|
||||
[JsonPropertyName("group_id")] public uint GroupId { get; set; }
|
||||
|
||||
[JsonPropertyName("no_cache")] public bool NoCache { get; set; }
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Lagrange.OneBot.Core.Entity;
|
||||
|
||||
[Serializable]
|
||||
public class OneBotGroup(uint groupId, string groupName)
|
||||
{
|
||||
[JsonPropertyName("group_id")] public uint GroupId { get; set; } = groupId;
|
||||
|
||||
[JsonPropertyName("group_name")] public string GroupName { get; set; } = groupName;
|
||||
|
||||
[JsonPropertyName("member_count")] public int MemberCount { get; set; }
|
||||
|
||||
[JsonPropertyName("max_member_count")] public int MaxMemberCount { get; set; }
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using Lagrange.Core;
|
||||
using Lagrange.Core.Common.Interface.Api;
|
||||
using Lagrange.OneBot.Core.Entity.Action;
|
||||
|
||||
namespace Lagrange.OneBot.Core.Operation.Info;
|
||||
|
||||
[Operation("get_group_info")]
|
||||
public class GetGroupInfoOperation : IOperation
|
||||
{
|
||||
public async Task<OneBotResult> HandleOperation(string echo, BotContext context, JsonObject? payload)
|
||||
{
|
||||
if (payload.Deserialize<OneBotGetGroupInfo>() is { } message)
|
||||
{
|
||||
var result = await context.FetchGroups(message.NoCache);
|
||||
return new OneBotResult(result.FirstOrDefault(x => x.GroupUin == message.GroupId), 0, "ok", echo);
|
||||
}
|
||||
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using Lagrange.Core;
|
||||
using Lagrange.Core.Common.Interface.Api;
|
||||
using Lagrange.OneBot.Core.Entity.Action;
|
||||
|
||||
namespace Lagrange.OneBot.Core.Operation.Info;
|
||||
|
||||
[Operation("get_group_list")]
|
||||
public class GetGroupListOperation : IOperation
|
||||
{
|
||||
public async Task<OneBotResult> HandleOperation(string echo, BotContext context, JsonObject? payload)
|
||||
{
|
||||
if (payload.Deserialize<OneBotGetGroupInfo>() is { } message)
|
||||
{
|
||||
var result = await context.FetchGroups(message.NoCache);
|
||||
return new OneBotResult(result, 0, "ok", echo);
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await context.FetchGroups();
|
||||
return new OneBotResult(result, 0, "ok", echo);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -123,8 +123,8 @@ Please use Lagrange.Core responsibly and in accordance with the law.
|
|||
| [/get_login_info] | 🟢 |
|
||||
| [/get_stranger_info] | 🔴 |
|
||||
| [/get_friend_list] | 🔴 |
|
||||
| [/get_group_info] | 🔴 |
|
||||
| [/get_group_list] | 🔴 |
|
||||
| [/get_group_info] | 🟢 |
|
||||
| [/get_group_list] | 🟢 |
|
||||
| [/get_group_member_info] | 🔴 |
|
||||
| [/get_group_member_list] | 🔴 |
|
||||
| [/get_group_honor_info] | 🔴 |
|
||||
|
|
Loading…
Reference in New Issue