chore: cleanup
This commit is contained in:
@@ -18,39 +18,47 @@ public static class DependencyInjection
|
||||
public static IServiceCollection ConfigureServices(this IServiceCollection services, IConfiguration config)
|
||||
{
|
||||
services.AddSingleton(config);
|
||||
|
||||
services.AddScoped<ChannelBase, GrpcChannel>(_ => GrpcChannel.ForAddress(config.GetValue<string>("BackendHost")
|
||||
?? throw new MissingFieldException("Host is not defined")));
|
||||
|
||||
|
||||
services.AddScoped<ChannelBase, GrpcChannel>(_ => GrpcChannel.ForAddress(config.GetValue<string>("BackendHost")
|
||||
?? throw new MissingFieldException("Host is not defined")));
|
||||
|
||||
#region Commands
|
||||
|
||||
services.AddScoped<StartCommand>();
|
||||
services.AddScoped<MenuCommand>();
|
||||
services.AddScoped<InfoCommand>();
|
||||
|
||||
|
||||
//buttons
|
||||
services.AddScoped<EulaAgreementButtonCommand>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region gRPC Clients
|
||||
|
||||
services.AddGrpcClient<User.UserClient>(o => o.Address = new Uri("http://backend:5001"));
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Services
|
||||
|
||||
services.AddSingleton<UserService>();
|
||||
services.AddScoped<PrepareUserService>();
|
||||
services.AddScoped<MenuService>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region States
|
||||
|
||||
services.AddScoped<PrepareUserState>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
// Bot service
|
||||
services.AddHostedService<BotBackgroundService>();
|
||||
services.AddSingleton<ITelegramBotClient>(_ =>
|
||||
new TelegramBotClient(config.GetValue<string>("TelegramToken")
|
||||
services.AddSingleton<ITelegramBotClient>(_ =>
|
||||
new TelegramBotClient(config.GetValue<string>("TelegramToken")
|
||||
?? throw new MissingFieldException("TelegramToken is not set")));
|
||||
|
||||
|
||||
services.AddLogging(builder => builder.AddConsole());
|
||||
return services;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user