Skip to content

Releases: bvdcode/TelegramBot.NET

Release 1.0.18

10 Aug 08:03

Choose a tag to compare

Refactor HostApplicationLifetime retrieval and registration

Simplified and improved the retrieval and registration of the
HostApplicationLifetime service in BotApp.cs and BotBuilder.cs.
In BotApp.cs, the code now retrieves IHostApplicationLifetime
and casts it to HostApplicationLifetime, throwing an
InvalidOperationException if the cast fails. In BotBuilder.cs,
the registration of HostApplicationLifetime has been simplified
by removing the factory method and directly registering the
service. These changes enhance the robustness and clarity of
the code.

Release 1.0.17

10 Aug 07:51

Choose a tag to compare

Refactor BotApp to manage its own CancellationTokenSource

The constructor of the `BotApp` class in the `TelegramBot` namespace has been modified to remove the `cancellationTokenSource` parameter. Instead, a new `CancellationTokenSource` instance is created within the constructor.

In the `BotBuilder` class within the `TelegramBot.Builders` namespace, the instantiation of `CancellationTokenSource` has been removed, and the `BotApp` constructor is called without passing a `cancellationTokenSource` parameter.

These changes simplify the instantiation process of `BotApp` by encapsulating the creation of `CancellationTokenSource` within the class itself.

Release 1.0.16

10 Aug 07:27

Choose a tag to compare

Improve concurrent stopping of hosted services

Initialize a task list to track asynchronous stopping tasks of hosted services in the `TelegramBot` namespace within `BotApp.cs`. Modify the stopping logic to add each `StopAsync` task to the list and log the start of the stopping process. Await all tasks concurrently using `Task.WhenAll(tasks)` to potentially reduce the overall stopping time and provide clearer logging information.

Release 1.0.15

05 Aug 08:25

Choose a tag to compare

Merge branch 'main' of https://github.com/BigMakCode/TelegramBot.NET

Release 1.0.14

03 Aug 10:31

Choose a tag to compare

Add authorization for /help command and handler setup

- Updated `HomeController.cs` to include two new methods for handling the `/help` command, one authorized and one not.
- Modified `Program.cs` to include `TelegramBot.Extensions` namespace and use an authorization handler.
- Added `AuthorizationHandler.cs` to define `AuthorizationHandler` class implementing `IBotAuthorizationHandler` for user ID-based authorization.

Release 1.0.13

03 Aug 10:27

Choose a tag to compare

Add authorization mechanism for Telegram bot messages

Introduce a new authorization mechanism to enhance bot security.
- Add `TelegramBot.Attributes` namespace in `BotApp.cs`.
- Implement `AuthorizeAttribute` to mark methods/controllers.
- Retrieve `IBotAuthorizationHandler` for authorization logic.
- Handle unauthorized access without executing the method.
- Update parameter count check to handle null `args`.

Release 1.0.12

02 Aug 19:51

Choose a tag to compare

Refactor: Move IHost implementation to IBot interface

The BotApp class no longer implements the IHost interface directly.
Instead, the IBot interface now extends IHost, centralizing hosting
responsibilities within the IBot interface. This change ensures that
any class implementing IBot will also need to implement IHost.
Additionally, the necessary using directive for Microsoft.Extensions.Hosting
was added to IBot.cs.

Release 1.0.11

02 Aug 19:41

Choose a tag to compare

Implement IHost in BotApp and enhance lifecycle management

BotApp.cs:
- Implemented IHost interface in BotApp class.
- Added private field _disposed to track disposal state.
- Added CancellationTokenSource field _cancellationTokenSource.
- Updated constructor to accept a CancellationTokenSource parameter.
- Updated Run method to use a merged cancellation token.
- Added StartAsync, StopAsync, Dispose, and MergeTokens methods.
- Updated ErrorHandler, UpdateHandler, and HandleRequestAsync to call CheckDisposed.
- Added private method CheckDisposed to throw ObjectDisposedException.

BotBuilder.cs:
- Updated BotBuilder to create and pass a CancellationTokenSource to BotApp.

HostApplicationLifetime.cs:
- Updated to accept a CancellationTokenSource through its constructor.
- Removed creation of its own CancellationTokenSource.

Release 1.0.10

31 Jul 06:17

Choose a tag to compare

Remove LFS settings and package icon URL

Removed numerous lines from the .gitattributes file that specified various file types to be managed by Git LFS, including images, audio files, video files, documents, archives, and binaries. Additionally, the <PackageIconUrl> element was removed from the TelegramBot.csproj file, which previously specified the URL to the package icon hosted on GitHub.

Release 1.0.9

28 Jul 22:06

Choose a tag to compare

Add graceful shutdown using IHostApplicationLifetime

Introduce a mechanism to gracefully stop the application by leveraging the IHostApplicationLifetime interface.

- In BotApp.cs, call StopApplication() on IHostApplicationLifetime after logging that the bot has stopped.
- In BotBuilder.cs, reorganize using directives and register IHostApplicationLifetime as a singleton service.
- Add HostApplicationLifetime.cs to implement IHostApplicationLifetime, providing lifecycle event tokens and a method to stop the application.