Skip to content

Releases: gehongyan/Kook.Net

v0.9.5

13 Nov 10:07
Compare
Choose a tag to compare

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

12 Nov 15:42
Compare
Choose a tag to compare

Added

  • Added support for sending and modifying template messages.
    • Overloads for IMessageChannel.SendTextAsync, IMessageChannel.SendCardsAsync, IDMChannel.SendTextAsync, and IDMChannel.SendCardsAsync methods now accept parameters templateId, parameters, and jsonSerializerOptions for sending template messages.
    • Added TemplateId, Parameters, and JsonSerializerOptions properties to MessageProperties for modifying template messages.
    • Added MessageProperties<T> class to support passing generic-typed parameters arguments.
  • 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

27 Oct 12:47
Compare
Choose a tag to compare

Added

  • Added basic support for thread channels. Introduced the thread channel type ChannelType.Thread, and related entities IThreadChannel, RestThreadChannel, SocketThreadChannel. Added support for operations to get, create, modify, and delete thread channels.
  • Added permissions GuildPermission.ReplyToPost and ChannelPermission.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 respect RequestOptions.
  • Fixed the issue where IChannel.Name may be null.

Full Changelog: v0.9.2...v0.9.3

v0.9.2

18 Oct 12:45
Compare
Choose a tag to compare

Added

  • Support sending borderless theme CardTheme.Invisible cards
  • DefaultRestClient supports passing an IWebProxy instance
  • Implemented IEquatable<T> interface for Color, AlphaColor, and GradientColor

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

07 Sep 07:43
Compare
Choose a tag to compare

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

30 Aug 13:10
Compare
Choose a tag to compare

Update Roadmap

This update introduces the following new packages:

  • Kook.Net.Webhook: Webhook support package
  • Kook.Net.Webhook.HttpListener: Webhook implementation package for HTTP Listener
  • Kook.Net.Webhook.AspNet: Webhook implementation package integrated with ASP.NET
  • Kook.Net.MessageQueue.InMemory: In-memory message queue support package
  • Kook.Net.MessageQueue.MassTransit: MassTransit message queue support package
  • Kook.Net.DependencyInjection.Microsoft: Dependency injection extension package for Microsoft.Extensions.DependencyInjection
  • Kook.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, and Kook.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, and Kook.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 and IHostedService 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 and TimeOnly types, added support for parameter parsing of Uri type, and added command parsing for mixed text-image messages.
  • Added extension method MaybeTextImageMixedMessage on IUserMessage 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 and TryParse methods to the Color class.
  • IKookClient provides LoginAsync and LogoutAsync methods.
  • Added TagUtil to convert ITag to Tag<TKey, TValue>.

Fixed

  • Fixed the issue where the AudioClient.ClientDisconnected event was not correctly raised.
  • Fixed the issue where IsOwner on Rest/SocketGuildUser could be determined but the value was null.
  • 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 the IsAvailable property.
  • Fixed the issue where the values of EveryoneMention and HereMention in ITag might be 0 instead of 0U.

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 from ArgumentException to FormatException.
  • The return result of Emote.ToString has been changed to be equivalent to the result of ToKMarkdownString.
  • 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> to Tag<TKey, TValue>.
  • Adjusted the result of IUserMessage.Resolve to be more in line with the KMarkdown format.
  • Renamed the first parameter on ModuleBase.ReplyTextAsync to text.
  • Renamed SocketGuild.ValidBoostSubscriptions to SocketGuild.ActiveBoostSubscriptions.
  • The Kook.Net package no longer includes a reference to Kook.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

28 May 13:27
Compare
Choose a tag to compare

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 the Ready event.
  • Asynchronous: In asynchronous mode, after obtaining a simple list of guilds at client startup, the Ready 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, the Ready 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 reaches LargeNumberOfGuildsThreshold (default is 50), it will be Lazy; if it reaches SmallNumberOfGuildsThreshold (default is 5), it will be Asynchronous; otherwise, it will be Synchronous. 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 the StartupCacheFetchMode, LargeNumberOfGuildsThreshold, and SmallNumberOfGuildsThreshold 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 and AutoUpdateChannelPositions have been added to KookSocketConfig, defaulting to false. 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 adds CardEmbed.
  • Card entities and builders now implement IEquatable<T>.
  • SocketSelfUser now implements IUpdateable.
  • Added IGuild.RecommendInfo.Certifications.
  • 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.
  • 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 typed updated_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 as Obsolete, and MessageReference should be used instead.
  • fileName has been renamed to filename.
  • The filename parameter in the SendFileAsync overload that accepts the Stream type is now mandatory.
  • BaseSocketClient._baseConfig has been renamed to BaseConfig.
  • The event parameter Cacheable<SocketMessage, Guid> has been changed to Cacheable<IMessage, Guid> to address the issue of entity download failure.
  • SectionAccessoryMode.Unspecified has been removed; please use null instead.
  • Format.StripMarkDown has been renamed to StripMarkdown, and the original method has been marked as Obsolete.
  • 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

02 Apr 08:33
Compare
Choose a tag to compare

Update Path

The KOOK client now supports sending messages within voice channels. As a result, the following APIs have been modified:

  • CreateVoiceChannelProperties now inherits from CreateTextChannelProperties.
  • ModifyVoiceChannelProperties now inherits from ModifyTextChannelProperties.
  • IVoiceChannel now inherits from ITextChannel.
  • The value of ChannelPermissions.Voice now includes permissions for text channels.
  • The SocketTextChannel.GetMessagesAsync series of methods are now virtual methods, to be overridden by SocketVoiceChannel.

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 from ITextChannel, with relevant implementations updated.
  • Added SentRequest event to BaseKookClient.
  • Added non-null result prompts for parsing card message-related Try* methods.

Fixed

  • Corrected the issue with ConnectionManager incorrectly updating State when Disconnected.

Changes

  • Removed the Topic property from CreateTextChannelProperties.

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

28 Feb 09:56
Compare
Choose a tag to compare

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 handle ConnectionState when casted to IKookClient or BaseKookClient.

Changes

  • IVoiceChannel no longer derived from IMentionable interface.
  • Renamed the name of methods, variables, properties, and parameters from CancelToken to CancellationToken.

Misc

  • Updated document template, added example project page, and added voice streaming documentation.

Full Changelog: v0.5.5...v0.6.0

v0.5.5

02 Feb 04:54
Compare
Choose a tag to compare

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, and Remarks properties, and optional parameters to CommandAttribute 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 an IUser parameter.

Full Changelog: v0.5.4...v0.5.5