public async Task Handle(RemoveDescriptionCallback notification, CancellationToken ct) { var callback = notification.CallbackQuery; var descriptionId = notification.CallbackData.DescriptionId; var description = await mediator.Send(new GetStickerDescriptionQuery(descriptionId), ct); await mediator.Send(new RemoveStickerDescriptionCommand(descriptionId), ct); var descriptions = await mediator.Send(new GetStickerDescriptionsQuery(description.Sticker.Id), ct); await botClient.EditMessageReplyMarkupAsync( chatId : callback.Message.Chat, messageId : callback.Message.MessageId, replyMarkup : StickerDescriptionButtonsBuilder.BuildDescriptionMarkup(descriptions), cancellationToken : ct); }
public async Task Handle(BotListDescriptionsCommand notification, CancellationToken ct) { var message = notification.Message; if (message.ReplyToMessage?.Sticker is null) { throw new ValidationException("Must be a reply to a sticker"); } var sticker = message.ReplyToMessage.Sticker; var fromId = message.From.Id.ToString(); await mediator.Send(new EnsureStickerIsRegisteredCommand(sticker.FileUniqueId, sticker.FileId), ct); await mediator.Send(new EnsureUserIsRegisteredCommand(fromId), ct); var descriptions = await mediator.Send(new GetStickerDescriptionsQuery(sticker.FileUniqueId), ct).ToList(); if (descriptions.IsEmpty()) { await botClient.SendTextMessageAsync( chatId : message.Chat, text : "<i>This sticker has no descriptions</i>", parseMode : ParseMode.Html, replyToMessageId : message.MessageId, cancellationToken : ct); } else { await botClient.SendStickerAsync( chatId : message.Chat, sticker : message.ReplyToMessage.Sticker.FileId, replyToMessageId : message.MessageId, replyMarkup : StickerDescriptionButtonsBuilder.BuildDescriptionMarkup(descriptions), cancellationToken : ct); } }