diff --git a/BotNet.CommandHandlers/BotUpdate/Message/AICallCommandHandler.cs b/BotNet.CommandHandlers/BotUpdate/Message/AICallCommandHandler.cs index b98fb4b..bd830a8 100644 --- a/BotNet.CommandHandlers/BotUpdate/Message/AICallCommandHandler.cs +++ b/BotNet.CommandHandlers/BotUpdate/Message/AICallCommandHandler.cs @@ -15,7 +15,7 @@ IntentDetector intentDetector public async Task Handle(AICallCommand command, CancellationToken cancellationToken) { switch (command.CallSign) { - case "AI" or "Bot" or "GPT" when command.ImageFileId is null: { + case "AI" or "Bot" or "GPT" when command.ImageFileId is null && command.ReplyToMessage?.ImageFileId is null: { await _commandQueue.DispatchAsync( command: OpenAITextPrompt.FromAICallCommand( aiCallCommand: command, @@ -26,7 +26,7 @@ await _commandQueue.DispatchAsync( ); break; } - case "AI" or "Bot" or "GPT" when command.ImageFileId is { } imageFileId: { + case "AI" or "Bot" or "GPT" when command.ImageFileId is not null || command.ReplyToMessage?.ImageFileId is not null: { await _commandQueue.DispatchAsync( command: OpenAIImagePrompt.FromAICallCommand( aiCallCommand: command, diff --git a/BotNet.Commands/AI/OpenAI/OpenAIImagePrompt.cs b/BotNet.Commands/AI/OpenAI/OpenAIImagePrompt.cs index b38f78d..f416d4e 100644 --- a/BotNet.Commands/AI/OpenAI/OpenAIImagePrompt.cs +++ b/BotNet.Commands/AI/OpenAI/OpenAIImagePrompt.cs @@ -34,7 +34,12 @@ public static OpenAIImagePrompt FromAICallCommand(AICallCommand aiCallCommand, I } // File ID must be non-empty - if (string.IsNullOrWhiteSpace(aiCallCommand.ImageFileId)) { + string imageFileId; + if (!string.IsNullOrWhiteSpace(aiCallCommand.ImageFileId)) { + imageFileId = aiCallCommand.ImageFileId; + } else if (!string.IsNullOrWhiteSpace(thread.FirstOrDefault()?.ImageFileId)) { + imageFileId = thread.First().ImageFileId!; + } else { throw new ArgumentException("File ID must be non-empty.", nameof(aiCallCommand)); } @@ -52,7 +57,7 @@ public static OpenAIImagePrompt FromAICallCommand(AICallCommand aiCallCommand, I return new( callSign: aiCallCommand.CallSign, prompt: aiCallCommand.Text, - imageFileId: aiCallCommand.ImageFileId, + imageFileId: imageFileId, command: aiCallCommand, thread: thread );