* Fixed wrong UseTelegrator method using in web host

* Fixed HostedUpdateWebhooker service discovery
This commit is contained in:
2026-03-15 19:21:32 +04:00
parent ee78703cd1
commit ba772f3f7c
5 changed files with 7 additions and 5 deletions
@@ -94,7 +94,7 @@ public class TelegramBotWebHostBuilder : ITelegramBotHostBuilder
public TelegramBotWebHost Build()
{
TelegramBotWebHost host = new TelegramBotWebHost(_innerBuilder);
host.UseTelegrator();
host.UseTelegratorWeb();
return host;
}
@@ -15,7 +15,7 @@
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<Title>Telegrator.Hosting.Web</Title>
<Version>1.16.6</Version>
<Version>1.16.7</Version>
<Authors>Rikitav Tim4ik</Authors>
<Company>Rikitav Tim4ik</Company>
<RepositoryUrl>https://github.com/Rikitav/Telegrator</RepositoryUrl>
@@ -126,7 +126,9 @@ namespace Telegrator
/// </summary>
public static T UseTelegratorWeb<T>(this T app) where T : IEndpointRouteBuilder, IHost
{
HostedUpdateWebhooker webhooker = app.ServiceProvider.GetRequiredService<HostedUpdateWebhooker>();
if (app.ServiceProvider.GetServices<IHostedService>().FirstOrDefault(s => s is HostedUpdateWebhooker) is not HostedUpdateWebhooker webhooker)
throw new InvalidOperationException("No service for type 'Telegrator.Mediation.HostedUpdateWebhooker' has been registered.");
ITelegramBotInfo info = app.ServiceProvider.GetRequiredService<ITelegramBotInfo>();
IHandlersCollection handlers = app.ServiceProvider.GetRequiredService<IHandlersCollection>();
ILoggerFactory loggerFactory = app.ServiceProvider.GetRequiredService<ILoggerFactory>();