Adding missing Program.cs
This commit is contained in:
parent
571049eeb4
commit
e3b1a32535
35
Examples/DependencyInjection/Program.cs
Normal file
35
Examples/DependencyInjection/Program.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using DependencyInjection.Database;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using TelegramBotBase.Builder;
|
||||||
|
|
||||||
|
namespace DependencyInjection
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
static async Task Main(string[] args)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var serviceCollection = new ServiceCollection()
|
||||||
|
.AddDbContext<BotDbContext>(x => x.UseInMemoryDatabase("TelegramBotBase"));
|
||||||
|
|
||||||
|
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||||
|
|
||||||
|
var bot = BotBaseBuilder.Create()
|
||||||
|
.WithAPIKey(Environment.GetEnvironmentVariable("API_KEY") ??
|
||||||
|
throw new Exception("API_KEY is not set"))
|
||||||
|
.DefaultMessageLoop()
|
||||||
|
.WithServiceProvider<StartForm>(serviceProvider)
|
||||||
|
.NoProxy()
|
||||||
|
.NoCommands()
|
||||||
|
.NoSerialization()
|
||||||
|
.DefaultLanguage()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
await bot.Start();
|
||||||
|
await Task.Delay(-1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user