Releases: gehongyan/Kook.Net
v0.9.5
Added
- Added the Kook.Net.Pipe package, which provides
KookPipeClient
for sending pipe messages. - Added
TokenType.Pipe
, but it is only used to indicate the internal API client to log in with a pipe token type and should not be used for client login in user code.
Misc
- Removed the target framework .NET 7.0, added the target framework .NET 9.0.
Full Changelog: v0.9.4...v0.9.5
v0.9.4
Added
- Added support for sending and modifying template messages.
- Overloads for
IMessageChannel.SendTextAsync
,IMessageChannel.SendCardsAsync
,IDMChannel.SendTextAsync
, andIDMChannel.SendCardsAsync
methods now accept parameterstemplateId
,parameters
, andjsonSerializerOptions
for sending template messages. - Added
TemplateId
,Parameters
, andJsonSerializerOptions
properties toMessageProperties
for modifying template messages. - Added
MessageProperties<T>
class to support passing generic-typedparameters
arguments.
- Overloads for
- Text command framework now supports keyed services. The
FromKeyedServicesAttribute
can be used to obtain keyed service instances.
Fixed
- Fixed the issue where
SocketGuild.CurrentUser
was null. - Fixed an issue where direct messages might not be edited correctly.
Full Changelog: v0.9.3...v0.9.4
v0.9.3
Added
- Added basic support for thread channels. Introduced the thread channel type
ChannelType.Thread
, and related entitiesIThreadChannel
,RestThreadChannel
,SocketThreadChannel
. Added support for operations to get, create, modify, and delete thread channels. - Added permissions
GuildPermission.ReplyToPost
andChannelPermission.ReplyToPost
to represent the permission to reply to posts, and added support for post channel permissions in methods related to permissions. - Added
SocketRole.Members
, which can be used to retrieve all users with a specified role from the cache.
Fixed
- Fixed the issue where the
SocketGuildUser.RemoveRolesAsync
method did not respectRequestOptions
. - Fixed the issue where
IChannel.Name
may be null.
Full Changelog: v0.9.2...v0.9.3
v0.9.2
Added
- Support sending borderless theme
CardTheme.Invisible
cards DefaultRestClient
supports passing anIWebProxy
instance- Implemented
IEquatable<T>
interface forColor
,AlphaColor
, andGradientColor
Fixed
- Fixed symbol reference errors in some XML documents
- Fixed issue where attempting to get the message entity from a cacheable object returned by the send message method resulted in null
Other
- Enabled SourceLink
Full Changelog: v0.9.1...v0.9.2
v0.9.1
Fixed
- Fix the issue where the channel creator field being an empty string causes startup failure.
Full Changelog: v0.9.0...v0.9.1
v0.9.0
Update Roadmap
This update introduces the following new packages:
Kook.Net.Webhook
: Webhook support packageKook.Net.Webhook.HttpListener
: Webhook implementation package for HTTP ListenerKook.Net.Webhook.AspNet
: Webhook implementation package integrated with ASP.NETKook.Net.MessageQueue.InMemory
: In-memory message queue support packageKook.Net.MessageQueue.MassTransit
: MassTransit message queue support packageKook.Net.DependencyInjection.Microsoft
: Dependency injection extension package for Microsoft.Extensions.DependencyInjectionKook.Net.Hosting
: Hosting service extension package
The Kook.Net
package now references the Kook.Net.Webhook
package and has removed the reference to the Kook.Net.CardMarkup
package. If you need to continue using the functionality for building card messages via markup language, please reference the Kook.Net.CardMarkup
package separately.
Voice connection and streaming features have been changed to be implemented by an officially supported method. The newly added API for receiving voice data streams is experimental and not officially supported.
The exception thrown by Emote.Parse
when an error occurs has been changed from ArgumentException
to FormatException
. The return result of Emote.ToString
has been changed to be equivalent to the result of ToKMarkdownString
. The link format provided by MessageExtensions.GetJumpUrl
has been adjusted. SocketGuild.ValidBoostSubscriptions
has been changed to SocketGuild.ActiveBoostSubscriptions
. Tag<T>
has been changed to Tag<TKey, TValue>
.
Added
- Added support for custom message queues, with the default implementation being synchronous message processing. Support for setting the message queue provider by installing extension NuGet packages and configuring
KookSocketConfig.MessageQueueProvider
.Kook.Net.MessageQueue.InMemory
is the in-memory queue support package, andKook.Net.MessageQueue.MassTransit
is the MassTransit queue support package. Refer to the examples for usage. - Added support for Webhook mode, which is currently implemented based on the Socket implementation. The Webhook integrated by Kook.Net is the abstract class
KookWebhookClient
.Kook.Net.Webhook.HttpListener
is the Webhook implementation package for HTTP Listener, andKook.Net.Webhook.AspNet
is the Webhook implementation package integrated with ASP.NET. Refer to the examples for usage. - Added extension methods package for the Microsoft.Extensions.DependencyInjection dependency injection framework
Kook.Net.DependencyInjection.Microsoft
, to support quick addition of various clients from Kook.Net, refer to the examples for usage. - Added hosting service extension package based on
IHost
andIHostedService
Kook.Net.Hosting
, to support quick addition of various clients from Kook.Net as hosting services, refer to the examples for usage. - Added support for receiving voice data stream related APIs. (Experimental feature, not officially supported)
- The text command framework has added built-in support for parameter parsing of
DateOnly
andTimeOnly
types, added support for parameter parsing ofUri
type, and added command parsing for mixed text-image messages. - Added extension method
MaybeTextImageMixedMessage
onIUserMessage
to determine if it might be a mixed text-image message. - Made the constructor of
Emote
public. - Added
KookComparers
class to support KOOK entities comparison by ID. - Added
Parse
andTryParse
methods to theColor
class. IKookClient
providesLoginAsync
andLogoutAsync
methods.- Added
TagUtil
to convertITag
toTag<TKey, TValue>
.
Fixed
- Fixed the issue where the
AudioClient.ClientDisconnected
event was not correctly raised. - Fixed the issue where
IsOwner
onRest/SocketGuildUser
could be determined but the value wasnull
. - Fixed the issue where
RequireRoleAttribute
could be incorrectly added to inappropriate targets. - Fixed the issue where the server member update event threw an exception when the nickname parameter was not carried.
- Fixed the issue where the implementation on
IGuild
did not expose theIsAvailable
property. - Fixed the issue where the values of
EveryoneMention
andHereMention
inITag
might be0
instead of0U
.
Changed
- After user code manipulates server member roles via API, the framework will attempt to update the cache to get as accurate role information as possible without updating user role information via API.
- The exception thrown by
Emote.Parse
when an error occurs has been changed fromArgumentException
toFormatException
. - The return result of
Emote.ToString
has been changed to be equivalent to the result ofToKMarkdownString
. - Voice connection and streaming features have been changed to be implemented by an officially supported method.
- Changed the link format provided by
MessageExtensions.GetJumpUrl
, adjusted the server channel to the newly supported official link format, and adjusted the parameters in private chat channels to use chat codes. - Changed
Tag<T>
toTag<TKey, TValue>
. - Adjusted the result of
IUserMessage.Resolve
to be more in line with the KMarkdown format. - Renamed the first parameter on
ModuleBase.ReplyTextAsync
totext
. - Renamed
SocketGuild.ValidBoostSubscriptions
toSocketGuild.ActiveBoostSubscriptions
. - The
Kook.Net
package no longer includes a reference toKook.Net.CardMarkup
.
Removed
- Due to the deactivation of many unofficial interfaces, most APIs on Kook.Net.Experimental have been removed.
Misc
- XML documentation has been rewritten in Simplified Chinese.
- Added usage examples for MessageQueue, Webhook, and OAuth.
- Added Simplified Chinese README.
Full Changelog: v0.8.0...v0.9.0
v0.8.0
Update Roadmap
Due to changes in the KOOK API, Bot users can no longer obtain all the necessary basic guild information at startup through the /guild/index
API. Instead, it is now required to traverse each guild via the /guild/view
API. This change can result in a significantly longer startup time and a large number of API requests for Bots that have joined many guilds. Therefore, the current version introduces the KookSocketConfig.StartupCacheFetchMode
configuration item, which defines how the Bot loads the basic guild data needed at startup.
Synchronous
: In synchronous mode, after obtaining a simple list of guilds at client startup, the client fetches the basic data of each guild through the API before triggering theReady
event.Asynchronous
: In asynchronous mode, after obtaining a simple list of guilds at client startup, theReady
event is triggered immediately, and a background task is started to fetch all the basic guild data.Lazy
: In lazy mode, after obtaining a simple list of guilds at client startup, theReady
event is triggered immediately without proactively fetching the basic guild data. When events involving the guild are received from the gateway, the guild's basic data will be fetched through the API if it has not already been obtained.Auto
: In automatic mode, the default setting, the client's startup mode is automatically determined based on the number of guilds the Bot has joined. If the number of guilds reachesLargeNumberOfGuildsThreshold
(default is 50), it will beLazy
; if it reachesSmallNumberOfGuildsThreshold
(default is 5), it will beAsynchronous
; otherwise, it will beSynchronous
. This determination is made each time the Bot connects to the WebSocket.
When not using Synchronous
mode, after the Ready
event, accessing cached guild entities might result in entities that do not fully contain basic guild data. The IsAvailable
property indicates whether the guild entity has fully cached basic data through the API. In such cases, please proactively call the UpdateAsync
method to update the cached guild entity through the API. The basic guild data mentioned above mainly includes the guild's channels, roles, channel permission overrides, and the current user's nickname within guilds.
The entire framework code has been updated to support nullable reference static analysis diagnostics. For the concept of nullable reference types in C#, please refer to Nullable reference types - C# | Microsoft Learn. After updating to the current version, all values that may be null will be marked as nullable types. This may cause some code to generate warnings during compilation, which should be treated as potential null reference exceptions and fixed accordingly.
Additionally, IQuote
has a new implementation MessageReference
, which only contains the ID of the message to be referenced and is used when calling the API in user code. Existing user code that creates Quote
should migrate to MessageReference
as soon as possible.
fileName
has been renamed to filename
; the event parameter Cacheable<SocketMessage, Guid>
has been changed to Cacheable<IMessage, Guid>
; SectionAccessoryMode.Unspecified
is now replaced by null
; Format.StripMarkDown
has been renamed to StripMarkdown
; and the filename
parameter in the SendFileAsync
overload that accepts the Stream
type is now mandatory. Please note that these changes may cause compilation errors and should be fixed accordingly.
Additions
KookSocketConfig
adds theStartupCacheFetchMode
,LargeNumberOfGuildsThreshold
, andSmallNumberOfGuildsThreshold
configuration items to customize how the Bot's Socket client fetches the basic guild data needed at startup via the API.- Two new configuration properties
AutoUpdateRolePositions
andAutoUpdateChannelPositions
have been added toKookSocketConfig
, defaulting tofalse
. When enabled, the client will automatically fetch data via the API upon receiving related events to maintain the cached role and channel sorting information. Embed
addsCardEmbed
.- Card entities and builders now implement
IEquatable<T>
. SocketSelfUser
now implementsIUpdateable
.- Added
IGuild.RecommendInfo.Certifications
. IQuote
has a new implementationMessageReference
, which only contains the ID of the message to be referenced and is used when calling the API in user code.- Support for the event types
embeds_append
,sort_channel
,updated_server_type
,batch_added_channel
,batch_updated_channel
,batch_deleted_channel
,live_status_changed
,PERSON
typedupdated_guild
,add_guild_mute
,delete_guild_mute
,unread_count_changed
has been added, but it is not yet confirmed whether these events will actually be dispatched.
Fixes
- Fixed the issue where the author of private messages was incorrect.
- Fixed the issue where
SocketUserMessage.Quote.Author
could be null. - Fixed the issue where Tags were missing corresponding values when referencing nonexistent entities in messages.
- Fixed the issue where the voice client failed to handle undefined events, causing stream crashes.
- Fixed the issue where parsing newly introduced mixed media messages failed.
- Corrected the behavior of updating user nicknames.
Changes
- Enabled nullable reference types feature. For the concept of nullable reference types in C#, please refer to Nullable reference types - C# | Microsoft Learn.
- Various validations for the card builder are now deferred to the
Build
call. - The types of properties involving lists in cards have been changed to
IList<T>
. Quote.Empty
and its public constructor have been marked asObsolete
, andMessageReference
should be used instead.fileName
has been renamed tofilename
.- The
filename
parameter in theSendFileAsync
overload that accepts theStream
type is now mandatory. BaseSocketClient._baseConfig
has been renamed toBaseConfig
.- The event parameter
Cacheable<SocketMessage, Guid>
has been changed toCacheable<IMessage, Guid>
to address the issue of entity download failure. SectionAccessoryMode.Unspecified
has been removed; please usenull
instead.Format.StripMarkDown
has been renamed toStripMarkdown
, and the original method has been marked asObsolete
.Format.StripMarkdown
now removes hyphens-
.
Others
- Added a reference to
PolySharp
on .NET 7 and earlier target frameworks to support the implementation of some new features on older frameworks. - Added integration tests for some Socket events.
Full Changelog: v0.7.0...v0.8.0
v0.7.0
Update Path
The KOOK client now supports sending messages within voice channels. As a result, the following APIs have been modified:
CreateVoiceChannelProperties
now inherits fromCreateTextChannelProperties
.ModifyVoiceChannelProperties
now inherits fromModifyTextChannelProperties
.IVoiceChannel
now inherits fromITextChannel
.- The value of
ChannelPermissions.Voice
now includes permissions for text channels. - The
SocketTextChannel.GetMessagesAsync
series of methods are now virtual methods, to be overridden bySocketVoiceChannel
.
It's important to note that, due to limitations in the KOOK API, fetching message history and pinning messages are not supported within voice channels via the API. Therefore, calling GetMessagesAsync
and GetPinnedMessagesAsync
methods from IMessageChannel
on voice channels is not supported.
Additionally, while voice channels support operations on Topic
and SlowModeInterval
at the API level, the KOOK client currently does not reflect these capabilities.
Creating channels does not immediately support specifying a Topic. The Topic
property in CreateTextChannelProperties
has been removed and does not take effect. Please use the ITextChannel.ModifyAsync
method to modify the channel after creation.
Added
- Added support for defining card messages via XML. (#9 by @LiamSho)
IVoiceChannel
now inherits fromITextChannel
, with relevant implementations updated.- Added
SentRequest
event toBaseKookClient
. - Added non-null result prompts for parsing card message-related
Try*
methods.
Fixed
- Corrected the issue with
ConnectionManager
incorrectly updatingState
whenDisconnected
.
Changes
- Removed the
Topic
property fromCreateTextChannelProperties
.
Misc
- Marked the project as not supporting AOT and assembly trimming.
- Added example project
Kook.Net.Samples.CardMarkup
. (#9 by @LiamSho) - Added documentation for defining card messages via XML. (#9 by @LiamSho)
- Added Logo.
New Contributors
- @LiamSho made their first contribution in #9
Full Changelog: v0.6.0...v0.7.0
v0.6.0
Update Path
In KOOK, mentioning voice channels in text messages is not supported, meaning IVoiceChannel
should not be derived from IMentionable
interface. Incorrect usage of mentioning IVoiceChannel
should be removed or modified.
The name of the cancellation token has been changed from CancelToken
to CancellationToken
. Existing methods, variables, properties, and parameters related to cancellation token should be updated.
Added
- Added connection and streaming for voice channels.
Fixed
- Fixed an issue where
KookSocketClient
did not correctly handleConnectionState
when casted toIKookClient
orBaseKookClient
.
Changes
IVoiceChannel
no longer derived fromIMentionable
interface.- Renamed the name of methods, variables, properties, and parameters from
CancelToken
toCancellationToken
.
Misc
- Updated document template, added example project page, and added voice streaming documentation.
Full Changelog: v0.5.5...v0.6.0
v0.5.5
Update Path
RequireUserAttribute
no longer supports construction via the IUser
parameter; please use IUser.Id
instead.
Added
- Added
RequireRoleAttribute
as a precondition in the text command framework. - Added
Aliases
,Summary
, andRemarks
properties, and optional parameters toCommandAttribute
in the text command framework.
Fixed
- Fixed an issue where exceptions during data download at Bot startup were not properly outputted to the log.
Changed
- Removed the unrealistic constructor on
RequireUserAttribute
that accepted anIUser
parameter.
Full Changelog: v0.5.4...v0.5.5