private async Task OnCallbackAsync(CallbackQuery callback)
        {
            var message = callback.Message;

            log.Info($"[{message.Chat.Id}]: Received a callback: {callback.Data} from {AuthorToString(message)}");
            if (!settings.Interface.Telegram.Admins.Contains(message.Chat.Id))
            {
                log.Important($"Forbidden access to telegram user \"{message.Chat.Id}\" {message.From.Username ?? "(no nickname)"}");
                await client.SendTextMessageAsync(message.Chat.Id, $"Доступ с id \"{message.Chat.Id}\" не разрешён")
                .ConfigureAwait(false);

                return;
            }

            var callbackData = CallbackParser.ParseCallback(callback.Data);

            var response = await ReplyOnCallback(callbackData).ConfigureAwait(false);

            if (response.Markup is InlineKeyboardMarkup markup)
            {
                await EditMessageAsync(response.Text, markup, message).ConfigureAwait(false);
            }
            else
            {
                await SendResponseAsync(response, message).ConfigureAwait(false);
            }

            try
            {
                await client.AnswerCallbackQueryAsync(callback.Id).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                log.Warn(e.Message);
            }
        }
Example #2
0
 public static InlineKeyboardButton Stop(string service) => new InlineKeyboardButton
 {
     Text         = "Stop ⛔️",
     CallbackData = CallbackParser.CreateCallbackData(service, null, Commands.Stop)
 };
Example #3
0
 public static InlineKeyboardButton Restart(string service) => new InlineKeyboardButton
 {
     Text         = "Restart ♻️",
     CallbackData = CallbackParser.CreateCallbackData(service, null, Commands.Restart)
 };
Example #4
0
 public static InlineKeyboardButton Build(string service) => new InlineKeyboardButton
 {
     Text         = "Build 🔨",
     CallbackData = CallbackParser.CreateCallbackData(service, null, Commands.Build)
 };
Example #5
0
 public static InlineKeyboardButton Back() => new InlineKeyboardButton
 {
     Text         = "🔙",
     CallbackData = CallbackParser.CreateCallbackData(null, null, Commands.ListServices)
 };