Class RestThread
表示一个基于 REST 的帖子。
public class RestThread : RestEntity<ulong>, IThread, IEntity<ulong>, IDeletable, IUpdateable
- Inheritance
-
RestThread
- Implements
- Inherited Members
- Extension Methods
Properties
Attachments
获取此帖子所包含的所有附件。
public IReadOnlyCollection<IAttachment> Attachments { get; }
Property Value
AuditStatus
获取此帖子的审核状态。
public ThreadAuditStatus AuditStatus { get; }
Property Value
Author
获取此帖子的作者。
public IUser Author { get; }
Property Value
Cards
获取此帖子中包含的所有卡片。
public IReadOnlyCollection<ICard> Cards { get; }
Property Value
Remarks
warning
受限于 KOOK API,由 GetThreadsAsync(int, IThreadCategory?, RequestOptions?)
及其重载方法返回的帖子实体的此属性为 null
。要想获取此属性的值,请先在当前实体上调用 UpdateAsync(RequestOptions?) 方法。
Channel
获取此帖子所在的频道。
public IThreadChannel Channel { get; }
Property Value
Content
获取此帖子的内容。
public string? Content { get; }
Property Value
Remarks
此属性为卡片内容的原始代码。
ContentDeletedBy
获取此帖子内容被删除的原因。
public ThreadContentDeletedBy ContentDeletedBy { get; }
Property Value
Cover
获取此帖子的封面图片链接。
public string? Cover { get; }
Property Value
FavoriteCount
获取收藏此帖子的人数。
public int FavoriteCount { get; }
Property Value
Guild
获取此帖子所在的服务器。
public IGuild Guild { get; }
Property Value
IsContentDeleted
获取此帖子的内容是否已被删除。
public bool IsContentDeleted { get; }
Property Value
IsEdited
获取此帖子是否已被编辑。
public bool IsEdited { get; }
Property Value
LatestActiveTimestamp
获取此帖子最后一次活跃的时间。
public DateTimeOffset LatestActiveTimestamp { get; }
Property Value
MentionedChannelIds
获取此帖子中提及的所有频道。
public IReadOnlyCollection<ulong> MentionedChannelIds { get; }
Property Value
Remarks
warning
受限于 KOOK API,由 GetThreadsAsync(int, IThreadCategory?, RequestOptions?)
及其重载方法返回的帖子实体的此属性为 null
。要想获取此属性的值,请先在当前实体上调用 UpdateAsync(RequestOptions?) 方法。
MentionedEveryone
获取此帖子是否提及了全体成员。
public bool MentionedEveryone { get; }
Property Value
MentionedHere
获取此帖子是否提及了在线成员。
public bool MentionedHere { get; }
Property Value
MentionedRoleIds
获取此帖子中提及的所有角色的 ID。
public IReadOnlyCollection<uint> MentionedRoleIds { get; }
Property Value
Remarks
warning
受限于 KOOK API,由 GetThreadsAsync(int, IThreadCategory?, RequestOptions?)
及其重载方法返回的帖子实体的此属性为 null
。要想获取此属性的值,请先在当前实体上调用 UpdateAsync(RequestOptions?) 方法。
MentionedUserIds
获取此帖子中提及的所有用户的 ID。
public IReadOnlyCollection<ulong> MentionedUserIds { get; }
Property Value
Remarks
warning
受限于 KOOK API,由 GetThreadsAsync(int, IThreadCategory?, RequestOptions?)
及其重载方法返回的帖子实体的此属性为 null
。要想获取此属性的值,请先在当前实体上调用 UpdateAsync(RequestOptions?) 方法。
MentionedUsers
获取此帖子中提及的所有用户。
public IReadOnlyCollection<RestUser> MentionedUsers { get; }
Property Value
Remarks
warning
受限于 KOOK API,由 GetThreadsAsync(int, IThreadCategory?, RequestOptions?)
及其重载方法返回的帖子实体的此属性为 null
。要想获取此属性的值,请先在当前实体上调用 UpdateAsync(RequestOptions?) 方法。
PostCount
获取此帖子的评论数量。
public int PostCount { get; }
Property Value
PostId
获取此帖子主楼的评论 ID。
public ulong PostId { get; }
Property Value
Remarks
帖子的发布者在发布帖子时所发布的内容为主楼。
PreviewContent
获取此帖子内容的预览文本。
public string PreviewContent { get; }
Property Value
ThreadTags
获取此帖子所包含的所有话题标签。
public IReadOnlyCollection<ThreadTag> ThreadTags { get; }
Property Value
Timestamp
获取此帖子的发布时间。
public DateTimeOffset Timestamp { get; }
Property Value
Title
获取此帖子的标题。
public string Title { get; }
Property Value
Methods
CreatePostAsync(ICard, RequestOptions?)
在此帖子中创建一条帖子评论。
public Task<IThreadPost> CreatePostAsync(ICard card, RequestOptions? options = null)
Parameters
card
ICard要发布的卡片内容。
options
RequestOptions发送请求时要使用的选项。
Returns
- Task<IThreadPost>
一个表示新创建帖子评论操作的异步任务。
CreatePostAsync(IEnumerable<ICard>, RequestOptions?)
在此帖子中创建一条帖子评论。
public Task<IThreadPost> CreatePostAsync(IEnumerable<ICard> cards, RequestOptions? options = null)
Parameters
cards
IEnumerable<ICard>要发布的卡片内容。
options
RequestOptions发送请求时要使用的选项。
Returns
- Task<IThreadPost>
一个表示新创建帖子评论操作的异步任务。
CreatePostAsync(string, bool, RequestOptions?)
在此帖子中创建一条帖子评论。
public Task<IThreadPost> CreatePostAsync(string content, bool isKMarkdown = false, RequestOptions? options = null)
Parameters
content
string要发布的文本内容。
isKMarkdown
bool是否为 KMarkdown 格式。
options
RequestOptions发送请求时要使用的选项。
Returns
- Task<IThreadPost>
一个表示新创建帖子评论操作的异步任务。
DeleteAsync(RequestOptions?)
删除此实体对象及其所有子实体对象。
public Task DeleteAsync(RequestOptions? options = null)
Parameters
options
RequestOptions发送请求时要使用的选项。
Returns
DeleteContentAsync(RequestOptions?)
删除此帖子的主楼内容。
public Task DeleteContentAsync(RequestOptions? options = null)
Parameters
options
RequestOptions发送请求时要使用的选项。
Returns
- Task
一个表示帖子主楼内容删除操作的异步任务。
Remarks
当帖子无任何评论时,删除主楼内容会导致帖子被删除。
DeletePostAsync(IThreadPost, RequestOptions?)
删除此帖子内的一条帖子评论。
public Task DeletePostAsync(IThreadPost post, RequestOptions? options = null)
Parameters
post
IThreadPost要删除的帖子评论。
options
RequestOptions发送请求时要使用的选项。
Returns
- Task
一个表示帖子评论删除操作的异步任务。
Remarks
如果帖子的主楼内容已被删除,且此帖子评论是所属帖子的唯一一条评论,则删除此帖子评论会导致该帖子也被删除。
DeletePostAsync(ulong, RequestOptions?)
删除此帖子内的一条帖子评论。
public Task DeletePostAsync(ulong postId, RequestOptions? options = null)
Parameters
postId
ulong要删除的帖子评论的 ID。
options
RequestOptions发送请求时要使用的选项。
Returns
- Task
一个表示帖子评论删除操作的异步任务。
Remarks
如果帖子的主楼内容已被删除,且此帖子评论是所属帖子的唯一一条评论,则删除此帖子评论会导致该帖子也被删除。
DeleteReplyAsync(IThreadReply, RequestOptions?)
删除此帖子内的帖子评论内的一条帖子回复。
public Task DeleteReplyAsync(IThreadReply reply, RequestOptions? options = null)
Parameters
reply
IThreadReply要删除的帖子评论的回复。
options
RequestOptions发送请求时要使用的选项。
Returns
- Task
一个表示帖子评论的回复删除操作的异步任务。
DeleteReplyAsync(ulong, RequestOptions?)
删除此帖子内的帖子评论内的一条帖子回复。
public Task DeleteReplyAsync(ulong replyId, RequestOptions? options = null)
Parameters
replyId
ulong要删除的帖子评论的回复的 ID。
options
RequestOptions发送请求时要使用的选项。
Returns
- Task
一个表示帖子评论的回复删除操作的异步任务。
GetPostsAsync(IThreadPost, SortMode, int, RequestOptions?)
获取此帖子中的一些评论。
public IAsyncEnumerable<IReadOnlyCollection<IThreadPost>> GetPostsAsync(IThreadPost referencePost, SortMode sortMode = SortMode.Ascending, int limit = 30, RequestOptions? options = null)
Parameters
referencePost
IThreadPost要开始获取评论的参考位置的评论,获取的结果不包含此评论。
sortMode
SortMode要以参考位置为基准,获取评论的排序方式。
limit
int要获取的评论数量。
options
RequestOptions发送请求时要使用的选项。
Returns
- IAsyncEnumerable<IReadOnlyCollection<IThreadPost>>
分页的评论集合的异步可枚举对象。
Remarks
important
返回的集合是一个异步可枚举对象;调用 FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>) 可以异步枚举所有分页,并将其合并为一个集合。
warning
请勿一次性获取过多评论,这可能会导致抢占式速率限制,甚至触发实际的速率限制,从而导致 Bot 服务暂停。
此方法将尝试获取此最新的
limit
条评论。此方法会根据 MaxThreadsPerBatch
将请求拆分。换句话说,如果要获取 300 条评论,而 MaxThreadsPerBatch 的常量为
30
,则请求将被拆分为 10 个单独请求,因此异步枚举器会异步枚举返回 10 个响应。
FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>)
方法可以展开这 10 个响应返回的集合,并将其合并为一个集合。
GetPostsAsync(DateTimeOffset, SortMode, int, RequestOptions?)
获取此帖子中的一些评论。
public IAsyncEnumerable<IReadOnlyCollection<IThreadPost>> GetPostsAsync(DateTimeOffset referenceTimestamp, SortMode sortMode = SortMode.Ascending, int limit = 30, RequestOptions? options = null)
Parameters
referenceTimestamp
DateTimeOffsetsortMode
SortMode要以参考位置为基准,获取评论的排序方式。
limit
int要获取的评论数量。
options
RequestOptions发送请求时要使用的选项。
Returns
- IAsyncEnumerable<IReadOnlyCollection<IThreadPost>>
分页的评论集合的异步可枚举对象。
Remarks
important
返回的集合是一个异步可枚举对象;调用 FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>) 可以异步枚举所有分页,并将其合并为一个集合。
warning
请勿一次性获取过多评论,这可能会导致抢占式速率限制,甚至触发实际的速率限制,从而导致 Bot 服务暂停。
此方法将尝试获取此最新的
limit
条评论。此方法会根据 MaxThreadsPerBatch
将请求拆分。换句话说,如果要获取 300 条评论,而 MaxThreadsPerBatch 的常量为
30
,则请求将被拆分为 10 个单独请求,因此异步枚举器会异步枚举返回 10 个响应。
FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>)
方法可以展开这 10 个响应返回的集合,并将其合并为一个集合。
GetPostsAsync(int, RequestOptions?)
获取此帖子中的最新的一些评论。
public IAsyncEnumerable<IReadOnlyCollection<IThreadPost>> GetPostsAsync(int limit = 30, RequestOptions? options = null)
Parameters
limit
int要获取的评论数量。
options
RequestOptions发送请求时要使用的选项。
Returns
- IAsyncEnumerable<IReadOnlyCollection<IThreadPost>>
分页的评论集合的异步可枚举对象。
Remarks
important
返回的集合是一个异步可枚举对象;调用 FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>) 可以异步枚举所有分页,并将其合并为一个集合。
warning
请勿一次性获取过多评论,这可能会导致抢占式速率限制,甚至触发实际的速率限制,从而导致 Bot 服务暂停。
此方法将尝试获取此最新的
limit
条评论。此方法会根据 MaxThreadsPerBatch
将请求拆分。换句话说,如果要获取 300 条评论,而 MaxThreadsPerBatch 的常量为
30
,则请求将被拆分为 10 个单独请求,因此异步枚举器会异步枚举返回 10 个响应。
FlattenAsync<T>(IAsyncEnumerable<IEnumerable<T>>)
方法可以展开这 10 个响应返回的集合,并将其合并为一个集合。
UpdateAsync(RequestOptions?)
通过 REST API 获取此实体对象的最新状态,并替换当前对象的属性。
public Task UpdateAsync(RequestOptions? options = null)
Parameters
options
RequestOptions发送请求时要使用的选项。
Returns
- Task
一个表示异步更新操作的任务。
Remarks
warning
此方法将从 KOOK REST API 获取最新数据,并替换当前对象的属性,而非使用指定的属性修改 KOOK 服务端的数据。