/
Laxerem
/
BaskBot
Обзор
Документация
Войти
/
Laxerem
/
BaskBot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
BaskBot.Application/Bot/Abstractions/UserCommand.cs
26 строк
1 KB
Laxerem
[SAVED]: Start creating a KeyboardBuilder
06 янв 2026, 10:06
06 янв 2026, 10:06
c92a9e7
Код
Авторство
О чём код?
using BaskBot.Application.Bot.External.Events; using BaskBot.Application.Exceptions; using BaskBot.Core.Entities; using BaskBot.Database; using Microsoft.EntityFrameworkCore; using Telegram.Bot; namespace BaskBot.Application.Bot.Abstractions; public abstract class UserCommand : BaseCommand { private readonly DatabaseContext _dbContext; protected UserCommand(DatabaseContext database) { _dbContext = database; } public override async Task ExecuteAsync(ITelegramBotClient bot, MessageUserEvent evt, CancellationToken cancellationToken = default) { var user = await _dbContext.Users.AsNoTracking().FirstOrDefaultAsync(u => u.Id == evt.UserId, cancellationToken); if (user is null) { throw new NotAuthorizedException("User not found"); } await ExecuteAsync(bot, evt, user, cancellationToken); } protected abstract Task ExecuteAsync(ITelegramBotClient bot, MessageUserEvent evt, User user, CancellationToken cancellationToken = default); }