Skip to content

Commit

Permalink
Merge pull request #62 from GodLeaveMe/2.4
Browse files Browse the repository at this point in the history
some rework.
  • Loading branch information
ksharperd authored Nov 16, 2022
2 parents 4adb93f + 6a84a1c commit 840ee03
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 18 deletions.
11 changes: 9 additions & 2 deletions Mirai.Net/Data/Messages/MessageReceivers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,26 @@ public enum MessageReceivers
OtherClient,

/// <summary>
/// 好友同步消息
/// 好友消息的同步消息
/// </summary>
[Description("FriendSyncMessage")]
[EnumMember(Value = "FriendSyncMessage")]
FriendSync,

/// <summary>
/// 群同步消息
/// 群消息的同步消息
/// </summary>
[Description("GroupSyncMessage")]
[EnumMember(Value = "GroupSyncMessage")]
GroupSync,

/// <summary>
/// 临时消息的同步消息
/// </summary>
[Description("TempSyncMessage")]
[EnumMember(Value = "TempSyncMessage")]
TempSync,

/// <summary>
/// 未知类型的接收器
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public record FriendSyncMessageReceiver : MessageReceiverBase
/// <summary>
/// 好友信息
/// </summary>
[JsonProperty("subject")] public Friend Subject { get; set; }
[JsonProperty("subject")] public Friend TargetFriend { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public record GroupSyncMessageReceiver : MessageReceiverBase
/// <summary>
/// 群信息
/// </summary>
[JsonProperty("subject")] public Group Subject { get; set; }
[JsonProperty("subject")] public Group TargetGroup { get; set; }

}
}
27 changes: 27 additions & 0 deletions Mirai.Net/Data/Messages/Receivers/TempSyncMessageReceiver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Mirai.Net.Data.Shared;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Mirai.Net.Data.Messages.Receivers
{

/// <summary>
/// 群临时消息同步消息接收器
/// </summary>
public record TempSyncMessageReceiver : MessageReceiverBase
{

/// <summary>
/// 消息接收器类型
/// </summary>
public override MessageReceivers Type { get; set; } = MessageReceivers.TempSync;

/// <summary>
/// 目标群成员的信息
/// </summary>
[JsonProperty("subject")] public Member TargetMember { get; set; }

}
}
14 changes: 7 additions & 7 deletions Mirai.Net/Sessions/Http/Managers/FileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class FileManager
/// <summary>
/// 获取群文件列表
/// </summary>
/// <param name="target"></param>
/// <param name="groupId"></param>
/// <param name="withDownloadInfo">附带下载信息,默认不附带</param>
/// <param name="folderId">文件夹id,空字符串即为根目录</param>
/// <returns></returns>
Expand All @@ -41,7 +41,7 @@ public static async Task<IEnumerable<File>> GetFilesAsync(string groupId, bool?
/// <summary>
/// 获取群文件信息
/// </summary>
/// <param name="target">群号</param>
/// <param name="groupId">群号</param>
/// <param name="fileId">文件id</param>
/// <param name="withDownloadInfo"></param>
/// <returns></returns>
Expand All @@ -60,7 +60,7 @@ public static async Task<File> GetFileAsync(string groupId, string fileId, bool?
/// <summary>
/// 创建群文件夹
/// </summary>
/// <param name="target"></param>
/// <param name="groupId"></param>
/// <param name="name"></param>
/// <returns></returns>
public static async Task<File> CreateFolderAsync(string groupId, string name)
Expand All @@ -78,7 +78,7 @@ public static async Task<File> CreateFolderAsync(string groupId, string name)
/// <summary>
/// 删除群文件
/// </summary>
/// <param name="target"></param>
/// <param name="groupId"></param>
/// <param name="fileId"></param>
public static async Task DeleteFileAsync(string groupId, string fileId)
{
Expand All @@ -92,7 +92,7 @@ public static async Task DeleteFileAsync(string groupId, string fileId)
/// <summary>
/// 移动群文件
/// </summary>
/// <param name="target"></param>
/// <param name="groupId"></param>
/// <param name="fileId">移动文件id</param>
/// <param name="destination">移动目标文件夹id</param>
public static async Task MoveFileAsync(string groupId, string fileId, string destination)
Expand All @@ -108,7 +108,7 @@ public static async Task MoveFileAsync(string groupId, string fileId, string des
/// <summary>
/// 重命名群文件
/// </summary>
/// <param name="target"></param>
/// <param name="groupId"></param>
/// <param name="fileId">重命名文件id</param>
/// <param name="newName">新文件名</param>
public static async Task RenameFileAsync(string groupId, string fileId, string newName)
Expand All @@ -124,7 +124,7 @@ public static async Task RenameFileAsync(string groupId, string fileId, string n
/// <summary>
/// 上传群文件,参考https://github.com/project-mirai/mirai-api-http/issues/456
/// </summary>
/// <param name="target">上传到哪个群</param>
/// <param name="groupId">上传到哪个群</param>
/// <param name="filePath">文件的路径</param>
/// <param name="uploadPath">上传路径,例如/xx(不可以指定文件名,默认为上传到根目录)</param>
/// <returns>有几率返回null,这是个mirai-api-http的玄学问题</returns>
Expand Down
9 changes: 4 additions & 5 deletions Mirai.Net/Sessions/Http/Managers/MessageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,15 @@ public static async Task<T> GetMessageReceiverByIdAsync<T>(string messageId, str
/// <param name="timeStart">起始时间, UTC+8 时间戳, 单位为秒. 可以为 0, 即表示从可以获取的最早的消息起. 负数将会被看是 0.</param>
/// <param name="timeEnd">结束时间, UTC+8 时间戳, 单位为秒. 可以为 <c>long.MaxValue</c>, 即表示到可以获取的最晚的消息为止. 低于 timeStart 的值将会被看作是 timeStart 的值.</param>
/// <returns></returns>
public static async Task<IEnumerable<MessageChain>> GetRoamingMessagesAsync(string target, string timeStart, string timeEnd)
public static async Task<IEnumerable<MessageReceiverBase>> GetRoamingMessagesAsync(string target, long timeStart = 0, long timeEnd = 0)
{
var response = await HttpEndpoints.RoamingMessages.GetAsync(new
var response = await HttpEndpoints.RoamingMessages.PostJsonAsync(new
{
timeStart,
timeEnd,
target
target = target.ToInt64(),
});

return ((JArray)response.ToJObject()["data"]).Values<MessageChain>();
return JsonConvert.DeserializeObject<IEnumerable<MessageReceiverBase>>(response.Fetch("data"));
}

/// <summary>
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Mirai.Net 2.4.5
# Mirai.Net 2.4.6

Mirai.Net 是基于 [mirai-api-http] 实现的 C# 版轻量级 [mirai] 社区 SDK。

Expand Down Expand Up @@ -42,13 +42,15 @@ _斜体的标注的接口是不稳定的_
- 获取好友资料
- 获取群成员资料
- 获取陌生人资料
- 消息发送和撤回
- 消息操作
- 发送好友消息
- 发送群消息
- 发送临时会话消息
- 发送头像戳一戳消息
- 撤回消息
- 根据消息id获取消息链
- 监测同步消息
- 根据QQID获取好友漫游消息
- 文件操作
- 查看文件列表
- 获取文件信息
Expand Down

0 comments on commit 840ee03

Please sign in to comment.