Skip to content

Commit bdb23fc

Browse files
committed
Refactor BotBuilder and enhance TelegramServerBuilder
- Added service registration for IHostApplicationLifetime in BotBuilder.cs to manage application lifetime events. - Updated documentation for the BotBuilder constructor to clarify its intended use in ASP.NET Core applications. - Removed previous registration of IHostApplicationLifetime, indicating a refactor of service registrations. - Introduced UseConfiguration property in TelegramServerBuilder.cs to enhance configurability of the Telegram API base URL.
1 parent 14075ec commit bdb23fc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Sources/TelegramBot/Builders/BotBuilder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ public BotBuilder(params string[] args)
6060
Logging = new TelegramLoggerBuilder(Services);
6161
Services.AddSingleton(Configuration);
6262
Services.AddSingleton<IConfiguration>(Configuration);
63+
Services.AddSingleton<IHostApplicationLifetime, HostApplicationLifetime>();
6364
}
6465

6566
/// <summary>
66-
/// Initializes a new instance of the <see cref="BotBuilder"/> class with preconfigured defaults.
67+
/// Initializes a new instance of the <see cref="BotBuilder"/> class with preconfigured defaults. <br/>
68+
/// Supposes to be used in ASP.NET Core applications with <see cref="IHostApplicationBuilder"/>.
6769
/// </summary>
6870
/// <param name="hostBuilder">The host application builder.</param>
6971
/// <returns>The <see cref="BotBuilder"/>.</returns>
@@ -186,7 +188,6 @@ public IBot Build()
186188
{
187189
Services.AddSingleton<IKeyValueProvider, InMemoryKeyValueProvider>();
188190
}
189-
Services.AddSingleton<IHostApplicationLifetime, HostApplicationLifetime>();
190191
Services.AddHostedService<TelegramBotHostedService>();
191192
Services.AddSingleton(_botConfiguration);
192193
Services.AddSingleton<BotControllerMethodsContainer>();

Sources/TelegramBot/Builders/TelegramServerBuilder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public class TelegramServerBuilder
1010
/// </summary>
1111
public string? BaseUrl { get; set; }
1212

13+
/// <summary>
14+
/// Indicates whether to use the configuration value CustomTelegramApiUrl as the base URL.
15+
/// </summary>
1316
internal bool UseConfiguration { get; private set; }
1417

1518
/// <summary>

0 commit comments

Comments
 (0)