mirror of
https://github.com/Jetsparrow/karmabot.git
synced 2026-01-21 00:56:09 +03:00
17 lines
576 B
C#
17 lines
576 B
C#
namespace JetKarmaBot.Services.Handling;
|
|
|
|
public class DatabaseHandler : IRequestHandler
|
|
{
|
|
[Inject] private KarmaContextFactory Db;
|
|
[Inject] private Localization Locale;
|
|
public async Task Handle(RequestContext ctx, Func<RequestContext, Task> next)
|
|
{
|
|
using (var db = Db.GetContext())
|
|
{
|
|
ctx.AddFeature(db); // KarmaContext
|
|
ctx.AddFeature(Locale[(await db.Chats.FindAsync(ctx.EventArgs.Message.Chat.Id))?.Locale ?? "ru-ru"]); // Locale
|
|
await next(ctx);
|
|
await db.SaveChangesAsync();
|
|
}
|
|
}
|
|
} |