diff --git a/Mirai.Net.Test/Module1.cs b/Mirai.Net.Test/Module1.cs index 2b700ae..4894fd0 100644 --- a/Mirai.Net.Test/Module1.cs +++ b/Mirai.Net.Test/Module1.cs @@ -3,7 +3,6 @@ using Mirai.Net.Data.Messages; using Mirai.Net.Data.Messages.Concretes; using Mirai.Net.Data.Messages.Receivers; -using Mirai.Net.Data.Modules; using Mirai.Net.Modules; using Mirai.Net.Utils.Scaffolds; diff --git a/Mirai.Net/Data/Messages/Concretes/AppMessage.cs b/Mirai.Net/Data/Messages/Concretes/AppMessage.cs index b7d2414..a7fa93d 100644 --- a/Mirai.Net/Data/Messages/Concretes/AppMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/AppMessage.cs @@ -2,9 +2,18 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 小程序消息 +/// public class AppMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.App; + /// + /// 消息内容 + /// [JsonProperty("content")] public string Content { get; set; } } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/AtAllMessage.cs b/Mirai.Net/Data/Messages/Concretes/AtAllMessage.cs index eadb569..d1e33b6 100644 --- a/Mirai.Net/Data/Messages/Concretes/AtAllMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/AtAllMessage.cs @@ -1,6 +1,12 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// @全体成员 +/// public class AtAllMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.AtAll; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/AtMessage.cs b/Mirai.Net/Data/Messages/Concretes/AtMessage.cs index 68b2008..059b84e 100644 --- a/Mirai.Net/Data/Messages/Concretes/AtMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/AtMessage.cs @@ -2,13 +2,23 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// @某人 +/// public class AtMessage : MessageBase { + /// + /// 带参数的构造器 + /// + /// 要@的人的qq public AtMessage(string target) { Target = target; } + /// + /// + /// public AtMessage() { } @@ -25,5 +35,8 @@ public AtMessage() [JsonProperty("display")] internal string Display { get; set; } = ""; + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.At; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/DiceMessage.cs b/Mirai.Net/Data/Messages/Concretes/DiceMessage.cs index cb96d85..be2b81a 100644 --- a/Mirai.Net/Data/Messages/Concretes/DiceMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/DiceMessage.cs @@ -2,8 +2,14 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 骰子消息 +/// public class DiceMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Dice; /// diff --git a/Mirai.Net/Data/Messages/Concretes/FaceMessage.cs b/Mirai.Net/Data/Messages/Concretes/FaceMessage.cs index 81aa1a8..0c463e3 100644 --- a/Mirai.Net/Data/Messages/Concretes/FaceMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/FaceMessage.cs @@ -2,10 +2,13 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// qq表情 +/// public class FaceMessage : MessageBase { /// - /// QQ表情编号,可选,优先高于name + /// QQ表情编号,可选,优先高于 /// [JsonProperty("faceId")] public string FaceId { get; set; } @@ -16,5 +19,8 @@ public class FaceMessage : MessageBase [JsonProperty("name")] public string Name { get; set; } + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Face; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/FileMessage.cs b/Mirai.Net/Data/Messages/Concretes/FileMessage.cs index 3d45ebf..3866550 100644 --- a/Mirai.Net/Data/Messages/Concretes/FileMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/FileMessage.cs @@ -2,8 +2,14 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 文件 +/// public class FileMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.File; /// diff --git a/Mirai.Net/Data/Messages/Concretes/FlashImageMessage.cs b/Mirai.Net/Data/Messages/Concretes/FlashImageMessage.cs index ce8acb5..744c0cf 100644 --- a/Mirai.Net/Data/Messages/Concretes/FlashImageMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/FlashImageMessage.cs @@ -1,6 +1,12 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 闪照,构造方式与相同 +/// public class FlashImageMessage : ImageMessage { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.FlashImage; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/ForwardMessage.cs b/Mirai.Net/Data/Messages/Concretes/ForwardMessage.cs index a367ff6..692ea7a 100644 --- a/Mirai.Net/Data/Messages/Concretes/ForwardMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/ForwardMessage.cs @@ -3,8 +3,14 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 转发的消息 +/// public class ForwardMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Forward; /// @@ -13,6 +19,9 @@ public class ForwardMessage : MessageBase [JsonProperty("nodeList")] public IEnumerable NodeList { get; set; } + /// + /// 转发的消息节点 + /// public class ForwardNode { /// diff --git a/Mirai.Net/Data/Messages/Concretes/ImageMessage.cs b/Mirai.Net/Data/Messages/Concretes/ImageMessage.cs index 9629ed9..c1c3872 100644 --- a/Mirai.Net/Data/Messages/Concretes/ImageMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/ImageMessage.cs @@ -2,8 +2,14 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 图片 +/// public class ImageMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Image; /// diff --git a/Mirai.Net/Data/Messages/Concretes/JsonMessage.cs b/Mirai.Net/Data/Messages/Concretes/JsonMessage.cs index cc88c63..f4f1592 100644 --- a/Mirai.Net/Data/Messages/Concretes/JsonMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/JsonMessage.cs @@ -2,9 +2,16 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// json消息 +/// public class JsonMessage : MessageBase { + ///json文本 [JsonProperty("json")] public string Json { get; set; } + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Json; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/MarketFaceMessage.cs b/Mirai.Net/Data/Messages/Concretes/MarketFaceMessage.cs index 46023e4..1ee3a46 100644 --- a/Mirai.Net/Data/Messages/Concretes/MarketFaceMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/MarketFaceMessage.cs @@ -8,11 +8,20 @@ namespace Mirai.Net.Data.Messages.Concretes; /// public class MarketFaceMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.MarketFace; + /// + /// 表情id + /// [JsonProperty("id")] public string Id {get; set;} + /// + /// 表情名称 + /// [JsonProperty("name")] public string Name {get; set;} } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/MiraiCodeMessage.cs b/Mirai.Net/Data/Messages/Concretes/MiraiCodeMessage.cs index 03971f4..75374b4 100644 --- a/Mirai.Net/Data/Messages/Concretes/MiraiCodeMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/MiraiCodeMessage.cs @@ -3,8 +3,15 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// Mirai码, +/// 看这里 +/// public class MiraiCodeMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.MiraiCode; /// @@ -13,11 +20,18 @@ public class MiraiCodeMessage : MessageBase [JsonProperty("code")] public string Code { get; set; } + /// + /// 带参数的构造器 + /// + /// public MiraiCodeMessage(string code) { Code = code; } + /// + /// + /// public MiraiCodeMessage() { } diff --git a/Mirai.Net/Data/Messages/Concretes/MusicShareMessage.cs b/Mirai.Net/Data/Messages/Concretes/MusicShareMessage.cs index 5d5df1f..32aa201 100644 --- a/Mirai.Net/Data/Messages/Concretes/MusicShareMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/MusicShareMessage.cs @@ -2,21 +2,48 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 音乐分享 +/// public class MusicShareMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.MusicShare; + /// + /// 类型 + /// [JsonProperty("kind")] public string Kind { get; set; } + /// + /// 标题 + /// [JsonProperty("title")] public string Title { get; set; } + /// + /// 概述 + /// [JsonProperty("summary")] public string Summary { get; set; } + /// + /// 跳转链接 + /// [JsonProperty("jumpUrl")] public string JumpUrl { get; set; } + /// + /// 封面链接 + /// [JsonProperty("pictureUrl")] public string PictureUrl { get; set; } + /// + /// 音乐链接 + /// [JsonProperty("musicUrl")] public string MusicUrl { get; set; } + /// + /// 简介 + /// [JsonProperty("brief")] public string Brief { get; set; } } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/PlainMessage.cs b/Mirai.Net/Data/Messages/Concretes/PlainMessage.cs index afa328e..4c71ac7 100644 --- a/Mirai.Net/Data/Messages/Concretes/PlainMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/PlainMessage.cs @@ -2,18 +2,54 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 纯文本消息 +/// public class PlainMessage : MessageBase { + /// + /// 带参数的构造器 + /// + /// public PlainMessage(string text) { Text = text; } + /// + /// + /// public PlainMessage() { } + /// + /// 文本 + /// [JsonProperty("text")] public string Text { get; set; } + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Plain; + + /// + /// 可以和string相互转换 + /// + /// + /// + public static implicit operator PlainMessage(string s) + { + return new PlainMessage(s); + } + + /// + /// 可以和string相互转换 + /// + /// + /// + public static implicit operator string(PlainMessage plainMessage) + { + return plainMessage.Text; + } } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/PokeMessage.cs b/Mirai.Net/Data/Messages/Concretes/PokeMessage.cs index 40ddedd..4d16a79 100644 --- a/Mirai.Net/Data/Messages/Concretes/PokeMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/PokeMessage.cs @@ -2,6 +2,9 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 我也不知道是啥玩意 +/// public class PokeMessage : MessageBase { /// @@ -15,5 +18,8 @@ public class PokeMessage : MessageBase [JsonProperty("name")] public string Name { get; set; } + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Poke; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/QuoteMessage.cs b/Mirai.Net/Data/Messages/Concretes/QuoteMessage.cs index be9c07d..eeacd05 100644 --- a/Mirai.Net/Data/Messages/Concretes/QuoteMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/QuoteMessage.cs @@ -3,8 +3,14 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 引用消息 +/// public class QuoteMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Quote; /// diff --git a/Mirai.Net/Data/Messages/Concretes/SourceMessage.cs b/Mirai.Net/Data/Messages/Concretes/SourceMessage.cs index d00d110..8de2383 100644 --- a/Mirai.Net/Data/Messages/Concretes/SourceMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/SourceMessage.cs @@ -2,6 +2,10 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 源消息 +/// 仅在接收消息时有效,且总是消息链的第一个元素 +/// public class SourceMessage : MessageBase { /// @@ -16,5 +20,8 @@ public class SourceMessage : MessageBase [JsonProperty("time")] public string Time { get; set; } + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Source; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/VoiceMessage.cs b/Mirai.Net/Data/Messages/Concretes/VoiceMessage.cs index a17d9cf..80ad8e5 100644 --- a/Mirai.Net/Data/Messages/Concretes/VoiceMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/VoiceMessage.cs @@ -2,6 +2,9 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// 语音消息 +/// public class VoiceMessage : MessageBase { /// @@ -28,5 +31,8 @@ public class VoiceMessage : MessageBase [JsonProperty("base64")] public string Base64 { get; set; } + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Voice; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Concretes/XmlMessage.cs b/Mirai.Net/Data/Messages/Concretes/XmlMessage.cs index 20d7a82..f738c6c 100644 --- a/Mirai.Net/Data/Messages/Concretes/XmlMessage.cs +++ b/Mirai.Net/Data/Messages/Concretes/XmlMessage.cs @@ -2,9 +2,18 @@ namespace Mirai.Net.Data.Messages.Concretes; +/// +/// xml消息 +/// public class XmlMessage : MessageBase { + /// + /// 消息类型 + /// public override Messages Type { get; set; } = Messages.Xml; + /// + /// xml文本 + /// [JsonProperty("xml")] public string Xml { get; set; } } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/MessageBase.cs b/Mirai.Net/Data/Messages/MessageBase.cs index afa1a9b..2bac184 100644 --- a/Mirai.Net/Data/Messages/MessageBase.cs +++ b/Mirai.Net/Data/Messages/MessageBase.cs @@ -4,12 +4,22 @@ namespace Mirai.Net.Data.Messages; +/// +/// 所有消息的基类 +/// public class MessageBase { + /// + /// 消息类型 + /// [JsonProperty("type")] [JsonConverter(typeof(StringEnumConverter))] public virtual Messages Type { get; set; } + /// + /// 实际上是转换成json文本 + /// + /// public override string ToString() { return this.ToJsonString(); diff --git a/Mirai.Net/Data/Messages/MessageReceiverBase.cs b/Mirai.Net/Data/Messages/MessageReceiverBase.cs index 2cfead4..cc1571d 100644 --- a/Mirai.Net/Data/Messages/MessageReceiverBase.cs +++ b/Mirai.Net/Data/Messages/MessageReceiverBase.cs @@ -4,11 +4,20 @@ namespace Mirai.Net.Data.Messages; +/// +/// 消息接收器基类 +/// public class MessageReceiverBase { + /// + /// 消息接收器类型 + /// [JsonProperty("type")] [JsonConverter(typeof(StringEnumConverter))] public virtual MessageReceivers Type { get; set; } + /// + /// 接受到的消息链 + /// [JsonProperty("messageChain")] public MessageChain MessageChain { get; set; } } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/MessageReceivers.cs b/Mirai.Net/Data/Messages/MessageReceivers.cs index 719b20f..a5849b9 100644 --- a/Mirai.Net/Data/Messages/MessageReceivers.cs +++ b/Mirai.Net/Data/Messages/MessageReceivers.cs @@ -3,20 +3,38 @@ namespace Mirai.Net.Data.Messages; +/// +/// 消息接收器的类型 +/// public enum MessageReceivers { + /// + /// 好友消息 + /// [Description("FriendMessage")] [EnumMember(Value = "FriendMessage")] Friend, + /// + /// 群消息 + /// [Description("GroupMessage")] [EnumMember(Value = "GroupMessage")] Group, + /// + /// 临时消息 + /// [Description("TempMessage")] [EnumMember(Value = "TempMessage")] Temp, + /// + /// 陌生人消息 + /// [Description("StrangerMessage")] [EnumMember(Value = "StrangerMessage")] Stranger, + /// + /// 其它客户端消息 + /// [Description("OtherClientMessage")] [EnumMember(Value = "OtherClientMessage")] OtherClient } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Messages.cs b/Mirai.Net/Data/Messages/Messages.cs index 5b990cb..36b5fb5 100644 --- a/Mirai.Net/Data/Messages/Messages.cs +++ b/Mirai.Net/Data/Messages/Messages.cs @@ -1,24 +1,84 @@ namespace Mirai.Net.Data.Messages; +/// +/// 消息类型 +/// public enum Messages { + /// + /// 源消息 + /// Source, + /// + /// 引用消息 + /// Quote, + /// + /// @消息 + /// At, + /// + /// @全体成员消息 + /// AtAll, + /// + /// qq表情消息 + /// Face, + /// + /// 纯文本消息 + /// Plain, + /// + /// 图片消息 + /// Image, + /// + /// 闪照消息 + /// FlashImage, + /// + /// 语音消息 + /// Voice, + /// + /// xml消息 + /// Xml, + /// + /// json消息 + /// Json, + /// + /// app消息 + /// App, + /// + /// 不知道是啥玩意消息 + /// Poke, + /// + /// 骰子消息 + /// Dice, + /// + /// 音乐分享消息 + /// MusicShare, + /// + /// 转发消息 + /// Forward, + /// + /// 文件消息 + /// File, + /// + /// 商城表情消息 + /// MarketFace, + /// + /// mirai码消息 + /// MiraiCode } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Receivers/FriendMessageReceiver.cs b/Mirai.Net/Data/Messages/Receivers/FriendMessageReceiver.cs index a8a7b46..7381547 100644 --- a/Mirai.Net/Data/Messages/Receivers/FriendMessageReceiver.cs +++ b/Mirai.Net/Data/Messages/Receivers/FriendMessageReceiver.cs @@ -3,27 +3,36 @@ namespace Mirai.Net.Data.Messages.Receivers; +/// +/// 好友消息接收器 +/// public class FriendMessageReceiver : MessageReceiverBase { + /// + /// 消息接收器类型 + /// public override MessageReceivers Type { get; set; } = MessageReceivers.Friend; + /// + /// 发送者,某好友 + /// [JsonProperty("sender")] public Friend Sender { get; set; } /// /// 好友昵称 /// [JsonIgnore] - public string Name => Sender.NickName; + public string FriendName => Sender.NickName; /// /// 好友备注 /// [JsonIgnore] - public string Remark => Sender.Remark; + public string FriendRemark => Sender.Remark; /// /// 好友QQ号 /// [JsonIgnore] - public string Id => Sender.Id; + public string FriendId => Sender.Id; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Receivers/GroupMessageReceiver.cs b/Mirai.Net/Data/Messages/Receivers/GroupMessageReceiver.cs index c48f341..f4a8107 100644 --- a/Mirai.Net/Data/Messages/Receivers/GroupMessageReceiver.cs +++ b/Mirai.Net/Data/Messages/Receivers/GroupMessageReceiver.cs @@ -3,27 +3,36 @@ namespace Mirai.Net.Data.Messages.Receivers; +/// +/// 群消息接收器s +/// public class GroupMessageReceiver : MessageReceiverBase { + /// + /// 消息接收器类型 + /// [JsonProperty("sender")] public Member Sender { get; set; } /// /// 群号 /// [JsonIgnore] - public string Id => Sender.Group.Id; + public string GroupId => Sender.Group.Id; /// /// 群名称 /// [JsonIgnore] - public string Name => Sender.Group.Name; + public string GroupName => Sender.Group.Name; /// /// bot在群内的权限 /// [JsonIgnore] - public Permissions Permission => Sender.Group.Permission; + public Permissions BotPermission => Sender.Group.Permission; + /// + /// 消息接收器类型 + /// public override MessageReceivers Type { get; set; } = MessageReceivers.Group; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Receivers/OtherClientMessageReceiver.cs b/Mirai.Net/Data/Messages/Receivers/OtherClientMessageReceiver.cs index aba4b4d..b80b0ad 100644 --- a/Mirai.Net/Data/Messages/Receivers/OtherClientMessageReceiver.cs +++ b/Mirai.Net/Data/Messages/Receivers/OtherClientMessageReceiver.cs @@ -3,9 +3,18 @@ namespace Mirai.Net.Data.Messages.Receivers; +/// +/// 其他客户端消息接收器 +/// public class OtherClientMessageReceiver : MessageReceiverBase { + /// + /// 消息接收器类型 + /// public override MessageReceivers Type { get; set; } = MessageReceivers.OtherClient; + /// + /// 发送者 + /// [JsonProperty("sender")] public OtherClient Sender { get; set; } } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Receivers/StrangerMessageReceiver.cs b/Mirai.Net/Data/Messages/Receivers/StrangerMessageReceiver.cs index 7713d48..77c8365 100644 --- a/Mirai.Net/Data/Messages/Receivers/StrangerMessageReceiver.cs +++ b/Mirai.Net/Data/Messages/Receivers/StrangerMessageReceiver.cs @@ -3,27 +3,30 @@ namespace Mirai.Net.Data.Messages.Receivers; +/// +/// 陌生人接收器 +/// public class StrangerMessageReceiver : MessageReceiverBase { + /// + /// 消息接收器类型 + /// public override MessageReceivers Type { get; set; } = MessageReceivers.Stranger; + /// + /// 发送者 + /// [JsonProperty("sender")] public Friend Sender { get; set; } /// /// 昵称 /// [JsonIgnore] - public string Name => Sender.NickName; - - /// - /// 备注 - /// - [JsonIgnore] - public string Remark => Sender.Remark; + public string StrangerName => Sender.NickName; /// /// QQ号 /// [JsonIgnore] - public string Id => Sender.Id; + public string StrangerId => Sender.Id; } \ No newline at end of file diff --git a/Mirai.Net/Data/Messages/Receivers/TempMessageReceiver.cs b/Mirai.Net/Data/Messages/Receivers/TempMessageReceiver.cs index a7ff785..c6b9d51 100644 --- a/Mirai.Net/Data/Messages/Receivers/TempMessageReceiver.cs +++ b/Mirai.Net/Data/Messages/Receivers/TempMessageReceiver.cs @@ -3,27 +3,36 @@ namespace Mirai.Net.Data.Messages.Receivers; +/// +/// 临时消息接收器 +/// public class TempMessageReceiver : MessageReceiverBase { + /// + /// 消息接收器类型 + /// public override MessageReceivers Type { get; set; } = MessageReceivers.Temp; + /// + /// 发送者 + /// [JsonProperty("sender")] public Member Sender { get; set; } /// /// 群号 /// [JsonIgnore] - public string Id => Sender.Group.Id; + public string GroupId => Sender.Group.Id; /// /// 群名称 /// [JsonIgnore] - public string Name => Sender.Group.Name; + public string GroupName => Sender.Group.Name; /// /// bot在群内的权限 /// [JsonIgnore] - public Permissions Permission => Sender.Group.Permission; + public Permissions BotPermission => Sender.Group.Permission; } \ No newline at end of file diff --git a/Mirai.Net/Data/Modules/CommandTriggerAttribute.cs b/Mirai.Net/Data/Modules/CommandTriggerAttribute.cs deleted file mode 100644 index 5fdb5cc..0000000 --- a/Mirai.Net/Data/Modules/CommandTriggerAttribute.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -namespace Mirai.Net.Data.Modules; - -/// -/// -/// /hello --arg1 value1 value2 --arg2 --arg3 -/// /: prefix -/// hello : name -/// -- : args separator -/// -/// -[AttributeUsage(AttributeTargets.Method)] -[Obsolete] -public class CommandTriggerAttribute : Attribute -{ - public CommandTriggerAttribute(string name, string prefix = "/", string argsSeparator = "-", bool equalName = false) - { - Prefix = prefix; - Name = name; - ArgsSeparator = argsSeparator; - EqualName = equalName; - } - - public string Prefix { get; set; } - - public string Name { get; set; } - - public string ArgsSeparator { get; set; } - - /// - /// 命令中是否只能包含Name - /// - public bool EqualName { get; set; } -} \ No newline at end of file diff --git a/Mirai.Net/Data/Shared/File.cs b/Mirai.Net/Data/Shared/File.cs index cf662fd..a8dde6d 100644 --- a/Mirai.Net/Data/Shared/File.cs +++ b/Mirai.Net/Data/Shared/File.cs @@ -3,52 +3,115 @@ namespace Mirai.Net.Data.Shared; +/// +/// 文件 +/// public class File { + /// + /// 文件名 + /// [JsonProperty("name")] public string Name { get; set; } + /// + /// 文件标识id + /// [JsonProperty("id")] public string Id { get; set; } + /// + /// 文件路径 + /// [JsonProperty("path")] public string Path { get; set; } + /// + /// 父目录 + /// [JsonProperty("parent")] public File Parent { get; set; } + /// + /// 是不是文件 + /// [JsonProperty("isFile")] public bool IsFile { get; set; } + /// + /// 是不是母鹿 + /// [JsonProperty("isDirectory")] public bool IsDirectory { get; set; } + /// + /// 上传者 + /// [JsonProperty("contact")] public FileUploader Contact { get; set; } + /// + /// 下载信息 + /// [JsonProperty("downloadInfo")] public FileDownloadInfo DownloadInfo { get; set; } + /// + /// 文件上传者 + /// public class FileUploader { + /// + /// 上传者qq + /// [JsonProperty("id")] public string Id { get; set; } + /// + /// 上传者昵称 + /// [JsonProperty("name")] public string Name { get; set; } + /// + /// 上传者在群内的权限 + /// [JsonProperty("permission")] [JsonConverter(typeof(StringEnumConverter))] public Permissions Permission { get; set; } } + /// + /// 文件下载信息 + /// public class FileDownloadInfo { + /// + /// sha1 + /// [JsonProperty("sha1")] public string Sha1 { get; set; } + /// + /// md5 + /// [JsonProperty("md5")] public string Md5 { get; set; } + /// + /// 下载链接 + /// [JsonProperty("url")] public string Url { get; set; } + /// + /// 下载次数 + /// [JsonProperty("downloadTimes")] public string DownloadTimes {get; set;} + /// + /// 上传者id + /// [JsonProperty("uploaderId")] public string UploaderId {get; set;} + /// + /// 上传时间戳 + /// [JsonProperty("uploadTime")] public string UploadTime {get; set;} + /// + /// 最后修改时间 + /// [JsonProperty("lastModifyTime")] public string LastModifyTime {get; set;} } diff --git a/Mirai.Net/Data/Shared/Friend.cs b/Mirai.Net/Data/Shared/Friend.cs index 40ad90a..aa5df32 100644 --- a/Mirai.Net/Data/Shared/Friend.cs +++ b/Mirai.Net/Data/Shared/Friend.cs @@ -3,9 +3,15 @@ namespace Mirai.Net.Data.Shared; +/// +/// 好友 +/// public class Friend { - [JsonIgnore] public Profile Profile => this.GetFriendProfileAsync().GetAwaiter().GetResult(); + /// + /// 好友的资料 + /// + [JsonIgnore] public Profile FriendProfile => this.GetFriendProfileAsync().GetAwaiter().GetResult(); /// /// 好友的QQ号 diff --git a/Mirai.Net/Data/Shared/Genders.cs b/Mirai.Net/Data/Shared/Genders.cs index af0f15e..786a36f 100644 --- a/Mirai.Net/Data/Shared/Genders.cs +++ b/Mirai.Net/Data/Shared/Genders.cs @@ -3,14 +3,26 @@ namespace Mirai.Net.Data.Shared; +/// +/// 发送者的性别 +/// public enum Genders { + /// + /// 男性 + /// [EnumMember(Value = "MALE")] [Description("MALE")] Male, + /// + /// 女性 + /// [EnumMember(Value = "FEMALE")] [Description("FEMALE")] Female, + /// + /// 未知 + /// [EnumMember(Value = "UNKNOWN")] [Description("UNKNOWN")] Unknown } \ No newline at end of file diff --git a/Mirai.Net/Data/Shared/Group.cs b/Mirai.Net/Data/Shared/Group.cs index b525b85..19b31ab 100644 --- a/Mirai.Net/Data/Shared/Group.cs +++ b/Mirai.Net/Data/Shared/Group.cs @@ -3,6 +3,9 @@ namespace Mirai.Net.Data.Shared; +/// +/// 群 +/// public class Group { /// diff --git a/Mirai.Net/Data/Shared/GroupSetting.cs b/Mirai.Net/Data/Shared/GroupSetting.cs index 6671db1..5b36fe1 100644 --- a/Mirai.Net/Data/Shared/GroupSetting.cs +++ b/Mirai.Net/Data/Shared/GroupSetting.cs @@ -2,6 +2,9 @@ namespace Mirai.Net.Data.Shared; +/// +/// 群设置 +/// public class GroupSetting { /// diff --git a/Mirai.Net/Data/Shared/ImageUploadTargets.cs b/Mirai.Net/Data/Shared/ImageUploadTargets.cs index 7aa1bab..f1d4194 100644 --- a/Mirai.Net/Data/Shared/ImageUploadTargets.cs +++ b/Mirai.Net/Data/Shared/ImageUploadTargets.cs @@ -3,14 +3,26 @@ namespace Mirai.Net.Data.Shared; +/// +/// 图片上传目标 +/// public enum ImageUploadTargets { + /// + /// 好友 + /// [Description("friend")] [EnumMember(Value = "friend")] Friend, + /// + /// 群 + /// [Description("group")] [EnumMember(Value = "group")] Group, + /// + /// 临时消息 + /// [Description("temp")] [EnumMember(Value = "temp")] Temp } \ No newline at end of file diff --git a/Mirai.Net/Data/Shared/Member.cs b/Mirai.Net/Data/Shared/Member.cs index 12ed8f7..bff4041 100644 --- a/Mirai.Net/Data/Shared/Member.cs +++ b/Mirai.Net/Data/Shared/Member.cs @@ -9,7 +9,10 @@ namespace Mirai.Net.Data.Shared; /// public class Member { - [JsonIgnore] public Profile Profile => this.GetMemberProfileAsync().GetAwaiter().GetResult(); + /// + /// 群员资料 + /// + [JsonIgnore] public Profile MmeberProfile => this.GetMemberProfileAsync().GetAwaiter().GetResult(); /// /// 群员的QQ号 diff --git a/Mirai.Net/Data/Shared/NewFriendRequestHandlers.cs b/Mirai.Net/Data/Shared/NewFriendRequestHandlers.cs index 333b5ba..c420621 100644 --- a/Mirai.Net/Data/Shared/NewFriendRequestHandlers.cs +++ b/Mirai.Net/Data/Shared/NewFriendRequestHandlers.cs @@ -1,8 +1,20 @@ namespace Mirai.Net.Data.Shared; +/// +/// 好友请求处理 +/// public enum NewFriendRequestHandlers { + /// + /// 同意 + /// Approve = 0, + /// + /// 拒绝 + /// Reject = 1, + /// + /// 拒绝并屏蔽 + /// RejectAndBlock = 2 } \ No newline at end of file diff --git a/Mirai.Net/Data/Shared/NewInvitationRequestHandlers.cs b/Mirai.Net/Data/Shared/NewInvitationRequestHandlers.cs index 0959301..7349593 100644 --- a/Mirai.Net/Data/Shared/NewInvitationRequestHandlers.cs +++ b/Mirai.Net/Data/Shared/NewInvitationRequestHandlers.cs @@ -1,7 +1,16 @@ namespace Mirai.Net.Data.Shared; +/// +/// 新入群邀请处理 +/// public enum NewInvitationRequestHandlers { + /// + /// 同意 + /// Approve, + /// + /// 拒绝 + /// Reject } \ No newline at end of file diff --git a/Mirai.Net/Data/Shared/NewMemberRequestHandlers.cs b/Mirai.Net/Data/Shared/NewMemberRequestHandlers.cs index d905352..f76975d 100644 --- a/Mirai.Net/Data/Shared/NewMemberRequestHandlers.cs +++ b/Mirai.Net/Data/Shared/NewMemberRequestHandlers.cs @@ -1,10 +1,28 @@ namespace Mirai.Net.Data.Shared; +/// +/// 新成员进群处理 +/// public enum NewMemberRequestHandlers { + /// + /// 同意 + /// Approve = 0, + /// + /// 拒绝 + /// Reject = 1, + /// + /// 忽略 + /// Dismiss = 2, + /// + /// 拒绝并拉黑 + /// RejectAndBlock = 3, + /// + /// 忽略 + /// DismissAndBlock = 4 } \ No newline at end of file diff --git a/Mirai.Net/Data/Shared/OtherClient.cs b/Mirai.Net/Data/Shared/OtherClient.cs index 3f386d2..6bb08a1 100644 --- a/Mirai.Net/Data/Shared/OtherClient.cs +++ b/Mirai.Net/Data/Shared/OtherClient.cs @@ -2,9 +2,18 @@ namespace Mirai.Net.Data.Shared; +/// +/// 其它客户端 +/// public class OtherClient { + /// + /// 客户端id + /// [JsonProperty("id")] public int Id { get; set; } + /// + /// 平台 + /// [JsonProperty("platform")] public string Platform { get; set; } } \ No newline at end of file diff --git a/Mirai.Net/Data/Shared/Permissions.cs b/Mirai.Net/Data/Shared/Permissions.cs index 37facd0..6e5a04c 100644 --- a/Mirai.Net/Data/Shared/Permissions.cs +++ b/Mirai.Net/Data/Shared/Permissions.cs @@ -3,14 +3,26 @@ namespace Mirai.Net.Data.Shared; +/// +/// 群内权限 +/// public enum Permissions { + /// + /// 群主 + /// [EnumMember(Value = "OWNER")] [Description("OWNER")] Owner, + /// + /// 管理员 + /// [EnumMember(Value = "ADMINISTRATOR")] [Description("ADMINISTRATOR")] Administrator, + /// + /// 群员 + /// [EnumMember(Value = "MEMBER")] [Description("MEMBER")] Member } \ No newline at end of file diff --git a/Mirai.Net/Data/Shared/Profile.cs b/Mirai.Net/Data/Shared/Profile.cs index 2f93df1..95a0744 100644 --- a/Mirai.Net/Data/Shared/Profile.cs +++ b/Mirai.Net/Data/Shared/Profile.cs @@ -3,14 +3,29 @@ namespace Mirai.Net.Data.Shared; +/// +/// 资料卡 +/// public class Profile { + /// + /// 昵称 + /// [JsonProperty("nickname")] public string NickName { get; set; } + /// + /// 邮箱 + /// [JsonProperty("email")] public string Email { get; set; } + /// + /// 年龄 + /// [JsonProperty("age")] public string Age { get; set; } + /// + /// 等级 + /// [JsonProperty("level")] public string Level { get; set; } /// @@ -19,6 +34,9 @@ public class Profile [JsonProperty("sign")] public string Signature { get; set; } + /// + /// 性别 + /// [JsonProperty("sex")] [JsonConverter(typeof(StringEnumConverter))] public Genders Gender { get; set; } diff --git a/Mirai.Net/Modules/ICommandModule.cs b/Mirai.Net/Modules/ICommandModule.cs deleted file mode 100644 index c001ad7..0000000 --- a/Mirai.Net/Modules/ICommandModule.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Mirai.Net.Data.Messages; -using Mirai.Net.Data.Modules; - -namespace Mirai.Net.Modules; - -[Obsolete("请使用IModule以体验全新的命令-模块系统")] -public interface ICommandModule -{ - public bool? IsEnable { get; set; } - - [CommandTrigger(nameof(ICommandModule))] - public void Execute(MessageReceiverBase receiver, MessageBase executeMessage); -} \ No newline at end of file diff --git a/Mirai.Net/Modules/IModule.cs b/Mirai.Net/Modules/IModule.cs index 8713c56..a1f7b7d 100644 --- a/Mirai.Net/Modules/IModule.cs +++ b/Mirai.Net/Modules/IModule.cs @@ -2,8 +2,19 @@ namespace Mirai.Net.Modules; +/// +/// 模块化接口 +/// public interface IModule { + /// + /// 执行器 + /// + /// void Execute(MessageReceiverBase @base); + + /// + /// 是否启用模块 + /// bool? IsEnable { get; set; } } \ No newline at end of file diff --git a/Mirai.Net/Utils/Scaffolds/MessageChain.cs b/Mirai.Net/Utils/Scaffolds/MessageChain.cs index b9d2524..17bbef7 100644 --- a/Mirai.Net/Utils/Scaffolds/MessageChain.cs +++ b/Mirai.Net/Utils/Scaffolds/MessageChain.cs @@ -10,12 +10,22 @@ // ReSharper disable once CheckNamespace namespace Mirai.Net.Data.Messages; +/// +/// 消息链 +/// public partial class MessageChain : List { + /// + /// AddRange + /// + /// public MessageChain(IEnumerable collection) : base(collection) { } + /// + /// + /// public MessageChain() : base() { } diff --git a/Mirai.Net/Utils/Scaffolds/MessageChainBuilder.cs b/Mirai.Net/Utils/Scaffolds/MessageChainBuilder.cs index 1f30cf5..c334709 100644 --- a/Mirai.Net/Utils/Scaffolds/MessageChainBuilder.cs +++ b/Mirai.Net/Utils/Scaffolds/MessageChainBuilder.cs @@ -4,6 +4,9 @@ namespace Mirai.Net.Utils.Scaffolds; +/// +/// 消息链建造者 +/// public class MessageChainBuilder { private readonly MessageChain _chain = new(); @@ -311,6 +314,10 @@ public MessageChainBuilder VoiceFromUrl(string url) return this; } + /// + /// 建造消息链 + /// + /// public MessageChain Build() { return _chain; diff --git a/Mirai.Net/Utils/Scaffolds/MessageScaffold.cs b/Mirai.Net/Utils/Scaffolds/MessageScaffold.cs index b0bfd0d..85c6a77 100644 --- a/Mirai.Net/Utils/Scaffolds/MessageScaffold.cs +++ b/Mirai.Net/Utils/Scaffolds/MessageScaffold.cs @@ -14,6 +14,12 @@ public static class MessageScaffold { #region Legacy + /// + /// + /// + /// + /// + /// public static MessageChain Append(this string origin, params MessageBase[] append) { var re = new MessageChain { new PlainMessage(origin) }; @@ -22,6 +28,12 @@ public static MessageChain Append(this string origin, params MessageBase[] appen return re; } + /// + /// + /// + /// + /// + /// public static MessageChain Append(this string origin, IEnumerable append) { var re = new MessageChain { new PlainMessage(origin) }; @@ -30,6 +42,12 @@ public static MessageChain Append(this string origin, IEnumerable a return re; } + /// + /// + /// + /// + /// + /// public static MessageChain Append(this string origin, string append) { var re = new MessageChain { new PlainMessage(origin), new PlainMessage(append) }; @@ -37,6 +55,12 @@ public static MessageChain Append(this string origin, string append) return re; } + /// + /// + /// + /// + /// + /// public static MessageChain Append(this MessageBase messageBase, params MessageBase[] append) { var re = new MessageChain { messageBase }; @@ -45,6 +69,12 @@ public static MessageChain Append(this MessageBase messageBase, params MessageBa return re; } + /// + /// + /// + /// + /// + /// public static MessageChain Append(this MessageBase messageBase, IEnumerable append) { var re = new MessageChain { messageBase }; @@ -53,6 +83,12 @@ public static MessageChain Append(this MessageBase messageBase, IEnumerable + /// + /// + /// + /// + /// public static MessageChain Append(this MessageBase messageBase, string append) { var re = new MessageChain { messageBase, new PlainMessage(append) }; @@ -60,6 +96,12 @@ public static MessageChain Append(this MessageBase messageBase, string append) return re; } + /// + /// + /// + /// + /// + /// public static MessageChain Append(this IEnumerable bases, params MessageBase[] append) { var re = bases.ToList(); @@ -68,6 +110,12 @@ public static MessageChain Append(this IEnumerable bases, params Me return re.ToMessageChain(); } + /// + /// + /// + /// + /// + /// public static MessageChain Append(this IEnumerable bases, string append) { var re = bases.ToList(); @@ -76,6 +124,12 @@ public static MessageChain Append(this IEnumerable bases, string ap return re.ToMessageChain(); } + /// + /// + /// + /// + /// + /// public static MessageChain Append(this IEnumerable bases, IEnumerable append) { var re = bases.ToList(); diff --git a/Mirai.Net/Utils/Scaffolds/MiraiScaffold.cs b/Mirai.Net/Utils/Scaffolds/MiraiScaffold.cs index 1307247..7dab4fb 100644 --- a/Mirai.Net/Utils/Scaffolds/MiraiScaffold.cs +++ b/Mirai.Net/Utils/Scaffolds/MiraiScaffold.cs @@ -15,6 +15,9 @@ namespace Mirai.Net.Utils.Scaffolds; +/// +/// mirai相关拓展方法 +/// public static class MiraiScaffold { #region MiraiBot extensions @@ -176,6 +179,12 @@ await MessageManager .RecallAsync(id); } + /// + /// 回复消息 + /// + /// + /// + /// public static async Task QuoteMessageAsync(this FriendMessageReceiver receiver, MessageChain chain) { @@ -185,6 +194,12 @@ public static async Task QuoteMessageAsync(this FriendMessageReceiver re .QuoteFriendMessageAsync(receiver.Sender.Id, id, chain); } + /// + /// 回复消息 + /// + /// + /// + /// public static async Task QuoteMessageAsync(this GroupMessageReceiver receiver, MessageChain chain) { @@ -194,6 +209,12 @@ public static async Task QuoteMessageAsync(this GroupMessageReceiver rec .QuoteGroupMessageAsync(receiver.Sender.Group.Id, id, chain); } + /// + /// 回复消息 + /// + /// + /// + /// public static async Task QuoteMessageAsync(this TempMessageReceiver receiver, MessageChain chain) { @@ -203,6 +224,12 @@ public static async Task QuoteMessageAsync(this TempMessageReceiver rece .QuoteTempMessageAsync(receiver.Sender.Id, receiver.Sender.Group.Id, id, chain); } + /// + /// 回复消息 + /// + /// + /// + /// public static async Task QuoteMessageAsync(this FriendMessageReceiver receiver, string message) { var id = receiver.MessageChain.OfType().First().MessageId; @@ -211,6 +238,12 @@ public static async Task QuoteMessageAsync(this FriendMessageReceiver re .QuoteFriendMessageAsync(receiver.Sender.Id, id, message); } + /// + /// 回复消息 + /// + /// + /// + /// public static async Task QuoteMessageAsync(this GroupMessageReceiver receiver, string message) { var id = receiver.MessageChain.ToList().OfType().First().MessageId; @@ -219,6 +252,12 @@ public static async Task QuoteMessageAsync(this GroupMessageReceiver rec .QuoteGroupMessageAsync(receiver.Sender.Group.Id, id, message); } + /// + /// 回复消息 + /// + /// + /// + /// public static async Task QuoteMessageAsync(this TempMessageReceiver receiver, string message) { var id = receiver.MessageChain.OfType().First().MessageId; diff --git a/Mirai.Net/Utils/Scaffolds/ModuleScaffold.cs b/Mirai.Net/Utils/Scaffolds/ModuleScaffold.cs index c4a9506..c55aaef 100644 --- a/Mirai.Net/Utils/Scaffolds/ModuleScaffold.cs +++ b/Mirai.Net/Utils/Scaffolds/ModuleScaffold.cs @@ -7,6 +7,9 @@ namespace Mirai.Net.Utils.Scaffolds; +/// +/// 模块化拓展方法 +/// public static class ModuleScaffold { /// @@ -32,7 +35,7 @@ public static IEnumerable GetModules(this T module) where T : IModul /// /// /// - public static void SubscribeModule(this IEnumerable modules, MessageReceiverBase @base) + public static void Raise(this IEnumerable modules, MessageReceiverBase @base) { foreach (var module in modules) { diff --git a/README.md b/README.md index e45f430..b85b177 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Mirai.Net 是基于[mirai-api-http]实现的轻量级[mirai]社区 sdk。 此项 项目文档: https://sinoahpx.github.io/Mirai.Net.Documents 如果你觉得这是个很酷的项目的话,不妨考虑给它点一个Star,如果你还觉得挺酷但还不够好的话,也欢迎提交Pull Request和Issue。 + + ## 速览 - 基于 [.NET Standard 2.0](https://docs.microsoft.com/en-us/dotnet/standard/net-standard) 开发,支持跨平台。 @@ -138,7 +140,7 @@ using Mirai.Net.Sessions; using var bot = new MiraiBot { Address = "localhost:8080", - QQ = xx, + QQ = "xx", VerifyKey = "xx" }; ``` @@ -181,13 +183,13 @@ bot.EventReceived 发送消息的方法有两个参数: 发送到哪里和发送什么。所以第一个参数就是发消息的群号,第二个参数就是要发送的消息链(或者字符串)。 ```cs -await manager.SendGroupMessageAsync("xx", "Hello, World"); +await MessageManager.SendGroupMessageAsync("xx", "Hello, World"); ``` 或者: ```cs -await manager.SendGroupMessageAsync("xx", new MessageChainBuilder().Plain("Hello, ").At("xx").Build()); +await MessageManager.SendGroupMessageAsync("xx", new MessageChainBuilder().Plain("Hello, ").At("xx").Build()); ``` ## 贡献