forked from Kakoluz/Jellyfin-Webhook-Telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
37 lines (25 loc) · 1.25 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Microsoft.EntityFrameworkCore;
using TelegramWebhooks.Helpers;
using TelegramWebhooks.Models;
using TelegramWebhooks.Services;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddMvc(options =>
{
options.InputFormatters.Insert(0, new TextPlainInputFormatter());
options.OutputFormatters.Insert(0, new TextPlainOutputFormatter());
});
builder.Services.Configure<AppSettings>(builder.Configuration.GetSection("AppSettings"));
var optionsBuilder = new DbContextOptionsBuilder<TelegramChatsContext>();
optionsBuilder.UseSqlite(builder.Configuration.GetConnectionString("MyConnectionString"));
var dbContext = new TelegramChatsContext(optionsBuilder.Options);
dbContext.Database.EnsureCreated();
dbContext.Database.Migrate();
builder.Services.AddDbContext<TelegramChatsContext>(opt => opt.UseSqlite(builder.Configuration.GetConnectionString("MyConnectionString")));
builder.Services.AddSingleton<ITelegramBotService, TelegramBotService>();
var app = builder.Build();
app.Services.GetService<ITelegramBotService>().sendNotificationAdmin("Notification service started");
// Configure the HTTP request pipeline.
app.MapControllers();
app.Run();