[SIS-xxx] adding multiline support and allowing multiple words for orange sun doge command alternative

This commit is contained in:
Sheldan
2025-07-21 17:18:46 +02:00
parent 1de0cae589
commit 7faafc9ad1
2 changed files with 5 additions and 6 deletions

View File

@@ -50,16 +50,13 @@ public class OrangeSunDogeCommandAlternative implements CommandAlternative {
@Override
public boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild, Message message) {
String contentStripped = message.getContentRaw();
String[] parameters = contentStripped.split(" ");
return parameters.length == 1 && featureFlagService.isFeatureEnabled(imageGenerationFeatureConfig, guild.getIdLong());
return featureFlagService.isFeatureEnabled(imageGenerationFeatureConfig, guild.getIdLong());
}
@Override
public void execute(UnParsedCommandParameter parameter, Message message) {
String contentStripped = message.getContentRaw();
List<String> parameters = Arrays.asList(contentStripped.split(" "));
String inputText = commandRegistry.getCommandName(parameters.get(0), message.getGuild().getIdLong());
String inputText = commandRegistry.getCommandName(contentStripped, message.getGuild().getIdLong());
File triggeredGifFile = imageGenerationService.getOrangeSunDogeImage(inputText);
MessageToSend messageToSend = templateService.renderEmbedTemplate(DOGE_ORANGE_SUN_RESPONSE_TEMPLATE_KEY, new Object(), message.getGuildIdLong());
// template support does not support binary files

View File

@@ -8,6 +8,8 @@ import org.springframework.stereotype.Component;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@Component
public class ImageGenerationService {
@@ -20,7 +22,7 @@ public class ImageGenerationService {
public File getOrangeSunDogeImage(String inputText) {
try {
return httpService.downloadFileToTempFile(dogeOrangeSunUrl.replace("{1}", inputText));
return httpService.downloadFileToTempFile(dogeOrangeSunUrl.replace("{1}", URLEncoder.encode(inputText, StandardCharsets.UTF_8)));
} catch (IOException e) {
throw new AbstractoRunTimeException(String.format("Failed to download orange doge image for url %s with error %s", inputText, e.getMessage()));
}