add tg bot project
This commit is contained in:
@@ -17,4 +17,8 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\GymLogAI.TgBot\GymLogAI.TgBot.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using GymLogAI.TgBot;
|
||||||
|
|
||||||
namespace GymLogAI.API;
|
namespace GymLogAI.API;
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
@@ -8,6 +10,7 @@ public class Program
|
|||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddAuthorization();
|
builder.Services.AddAuthorization();
|
||||||
|
builder.Services.AddTgBot(builder.Configuration);
|
||||||
|
|
||||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||||
builder.Services.AddOpenApi();
|
builder.Services.AddOpenApi();
|
||||||
|
|||||||
@@ -4,5 +4,8 @@
|
|||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"TelegramBot": {
|
||||||
|
"BotToken": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,8 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"TelegramBot": {
|
||||||
|
"BotToken": ""
|
||||||
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace GymLogAI.TgBot;
|
||||||
|
|
||||||
|
public sealed record TelegramBotOptions
|
||||||
|
{
|
||||||
|
public const string SectionName = "TelegramBot";
|
||||||
|
|
||||||
|
public string? BotToken { get; init; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace GymLogAI.TgBot;
|
||||||
|
|
||||||
|
public static class TgBotServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddTgBot(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(services);
|
||||||
|
ArgumentNullException.ThrowIfNull(configuration);
|
||||||
|
|
||||||
|
services
|
||||||
|
.AddOptions<TelegramBotOptions>()
|
||||||
|
.Bind(configuration.GetSection(TelegramBotOptions.SectionName));
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
compose.yaml = compose.yaml
|
compose.yaml = compose.yaml
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GymLogAI.TgBot", "GymLogAI.TgBot\GymLogAI.TgBot.csproj", "{BAF381C4-F522-4A59-B86D-3B9D3DA3D6AD}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -17,5 +19,9 @@ Global
|
|||||||
{42540161-196B-43B8-998E-FA9BDD01A74C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{42540161-196B-43B8-998E-FA9BDD01A74C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{42540161-196B-43B8-998E-FA9BDD01A74C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{42540161-196B-43B8-998E-FA9BDD01A74C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{42540161-196B-43B8-998E-FA9BDD01A74C}.Release|Any CPU.Build.0 = Release|Any CPU
|
{42540161-196B-43B8-998E-FA9BDD01A74C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BAF381C4-F522-4A59-B86D-3B9D3DA3D6AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BAF381C4-F522-4A59-B86D-3B9D3DA3D6AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BAF381C4-F522-4A59-B86D-3B9D3DA3D6AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BAF381C4-F522-4A59-B86D-3B9D3DA3D6AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Reference in New Issue
Block a user