public override void ExecuteAsync(string[] args) { if (args.Length != 1) { writer.WriteLine($"Wrong arguments. Try help {Name}"); return; } var caption = generator.GetCaption(args[0]); writer.WriteLine($"Caption: {caption}"); }
public async Task ExecuteAsync(Message message, TelegramBotClient botClient) { await botClient.SendChatActionAsync(message.Chat.Id, ChatAction.UploadPhoto); var filepath = await botClient.DownloadPhotoFromMessageAsync(message); var caption = generator.GetCaption(filepath); var fileName = filepath.Split(Path.DirectorySeparatorChar).Last(); await using (var fileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read)) { await botClient.SendPhotoAsync( chatId : message.Chat.Id, photo : new InputOnlineFile(fileStream, fileName), caption : caption, replyMarkup : new ReplyKeyboardRemove() ); } System.IO.File.Delete(filepath); }