-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from GodLeaveMe/2.4
add support for announcement.
- Loading branch information
Showing
8 changed files
with
363 additions
and
6 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
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
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
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,53 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Mirai.Net.Data.Shared | ||
{ | ||
/// <summary> | ||
/// 群公告 | ||
/// </summary> | ||
public record Announcement | ||
{ | ||
/// <summary> | ||
/// 群信息 | ||
/// </summary> | ||
[JsonProperty("group")] | ||
public Group Group { get; set; } | ||
|
||
/// <summary> | ||
/// 群公告内容 | ||
/// </summary> | ||
[JsonProperty("content")] | ||
public string Content { get; set; } | ||
|
||
/// <summary> | ||
/// 发布者账号 | ||
/// </summary> | ||
[JsonProperty("senderID")] | ||
public string SenderID { get; set; } | ||
|
||
/// <summary> | ||
/// 公告唯一id | ||
/// </summary> | ||
[JsonProperty("fid")] | ||
public string Fid { get; set; } | ||
|
||
/// <summary> | ||
/// 是否所有群成员已确认 | ||
/// </summary> | ||
[JsonProperty("allConfirmed")] | ||
public bool AllConfirmed { get; set; } | ||
|
||
/// <summary> | ||
/// 确认群成员人数 | ||
/// </summary> | ||
[JsonProperty("confirmedMembersCount")] | ||
public string ConfirmedMembersCount { get; set; } | ||
|
||
/// <summary> | ||
/// 发布时间 | ||
/// </summary> | ||
[JsonProperty("publicationTime")] | ||
public string PublicationTime { get; set; } | ||
|
||
} | ||
} |
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,72 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Mirai.Net.Data.Shared | ||
{ | ||
/// <summary> | ||
/// 群公告设置 | ||
/// </summary> | ||
public record AnnouncementSetting | ||
{ | ||
|
||
/// <summary> | ||
/// 群号 | ||
/// </summary> | ||
[JsonProperty("target")] | ||
public string Target { get; set; } | ||
|
||
/// <summary> | ||
/// 公告内容 | ||
/// </summary> | ||
[JsonProperty("content")] | ||
public string Content { get; set; } = ""; | ||
|
||
/// <summary> | ||
/// 是否发送给新成员 | ||
/// </summary> | ||
[JsonProperty("sendToNewMember")] | ||
public bool SendToNewMember { get; set; } = false; | ||
|
||
/// <summary> | ||
/// 是否置顶 | ||
/// </summary> | ||
[JsonProperty("pinned")] | ||
public bool Pinned { get; set; } = false; | ||
|
||
/// <summary> | ||
/// 是否显示群成员修改群名片的引导 | ||
/// </summary> | ||
[JsonProperty("showEditCard")] | ||
public bool ShowEditCard { get; set; } = false; | ||
|
||
/// <summary> | ||
/// 是否自动弹出 | ||
/// </summary> | ||
[JsonProperty("showPopup")] | ||
public bool ShowPopup { get; set; } = false; | ||
|
||
/// <summary> | ||
/// 是否需要群成员确认 | ||
/// </summary> | ||
[JsonProperty("requireConfirmation")] | ||
public bool RequireConfirmation { get; set; } = false; | ||
|
||
/// <summary> | ||
/// 公告图片url | ||
/// </summary> | ||
[JsonProperty("imageUrl")] | ||
public string ImageUrl { get; set; } | ||
|
||
/// <summary> | ||
/// 公告图片本地路径 | ||
/// </summary> | ||
[JsonProperty("imagePath")] | ||
public string ImagePath { get; set; } | ||
|
||
/// <summary> | ||
/// 公告图片base64编码 | ||
/// </summary> | ||
[JsonProperty("imageBase64")] | ||
public string ImageBase64 { get; set; } | ||
|
||
} | ||
} |
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,150 @@ | ||
using Manganese.Array; | ||
using Mirai.Net.Data.Events; | ||
using Mirai.Net.Data.Sessions; | ||
using Mirai.Net.Utils.Internal; | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using System.Reactive; | ||
using System.Threading.Tasks; | ||
|
||
namespace Mirai.Net.Sessions.Http.Managers | ||
{ | ||
|
||
/// <summary> | ||
/// 控制台管理器 | ||
/// </summary> | ||
/// 在功能稳定前保持可见性为 internal | ||
[Experimental] | ||
#if DEBUG | ||
public static class ConsoleManager | ||
#else | ||
internal static class ConsoleManager | ||
#endif | ||
{ | ||
|
||
/// <summary> | ||
/// 内部小把戏 | ||
/// </summary> | ||
/// 在功能稳定前使用此方法加入内部事件类型 | ||
static ConsoleManager() | ||
{ | ||
var field = typeof(ReflectionUtils).GetField("EventBases", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); | ||
if (field != null) | ||
{ | ||
if (field.GetValue(null) == null) | ||
{ | ||
field.SetValue(null, ReflectionUtils.GetDefaultInstances<EventBase>("Mirai.Net.Data.Events.Concretes")); | ||
} | ||
var eventBases = field.GetValue(null); | ||
((IEnumerable<EventBase>)eventBases).Add(new EventBase[] { new CommandExecutedEvent() }); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 执行命令 | ||
/// </summary> | ||
/// <param name="command"> | ||
/// <para>命令与参数</para> | ||
/// <para>控制台支持以不同消息类型作为指令的参数, 执行命令需要以消息类型作为参数, 若执行纯文本的命令, 构建多个文本格式的消息控制台会将第一个消息作为指令名, 后续消息作为参数</para> | ||
/// </param> | ||
/// <returns></returns> | ||
public static async Task ExecuteCommandAsync(object[] command) | ||
{ | ||
await HttpEndpoints.ExecuteCommand.PostJsonAsync(command); | ||
} | ||
|
||
/// <summary> | ||
/// <para>注册命令</para> | ||
/// <para>注册的命令会直接覆盖已有的指令(包括控制台内置的指令)</para> | ||
/// </summary> | ||
/// <param name="name">指令名</param> | ||
/// <param name="usage">使用说明</param> | ||
/// <param name="description">命令描述</param> | ||
/// <returns></returns> | ||
public static async Task RegisterCommandAsync(string name, string usage, string description) | ||
{ | ||
await HttpEndpoints.RegisterCommand.PostJsonAsync(new | ||
{ | ||
name, | ||
usage, | ||
description | ||
}); | ||
} | ||
|
||
/// <summary> | ||
/// <para>注册命令</para> | ||
/// <para>注册的命令会直接覆盖已有的指令(包括控制台内置的指令)</para> | ||
/// </summary> | ||
/// <param name="command">命令</param> | ||
/// <returns></returns> | ||
public static async Task RegisterCommandAsync(Command command) | ||
{ | ||
await HttpEndpoints.RegisterCommand.PostJsonAsync(command); | ||
} | ||
|
||
/// <summary> | ||
/// 命令 | ||
/// </summary> | ||
/// 在功能稳定前保持此类为内部类 | ||
public record Command | ||
{ | ||
|
||
/// <summary> | ||
/// 指令名 | ||
/// </summary> | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// 指令别名 | ||
/// </summary> | ||
[JsonProperty("alias")] | ||
public string[] Alias { get; set; } | ||
|
||
/// <summary> | ||
/// 使用说明 | ||
/// </summary> | ||
[JsonProperty("usage")] | ||
public string Usage { get; set; } | ||
|
||
/// <summary> | ||
/// 命令描述 | ||
/// </summary> | ||
[JsonProperty("description")] | ||
public string Description { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// 命令被执行 | ||
/// </summary> | ||
/// 在功能稳定前保持此类为内部类 | ||
public record CommandExecutedEvent : EventBase | ||
{ | ||
/// <summary> | ||
/// 事件类型 | ||
/// </summary> | ||
public override Events Type { get; set; } = Events.CommandExecuted; | ||
|
||
/// <summary> | ||
/// 命令名称 | ||
/// </summary> | ||
[JsonProperty("name")] public string Name { get; private set; } | ||
|
||
/// <summary> | ||
/// 发送命令的好友, 从控制台发送为 null | ||
/// </summary> | ||
[JsonProperty("friend")] public string FriendId { get; private set; } | ||
|
||
/// <summary> | ||
/// 发送命令的群成员, 从控制台发送为 nul | ||
/// </summary> | ||
[JsonProperty("member")] public string MemberId { get; private set; } | ||
|
||
/// <summary> | ||
/// 指令的参数, 以消息类型传递 | ||
/// </summary> | ||
[JsonProperty("args")] public dynamic Args { get; private set; } | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.