mirror of
https://github.com/Sheldan/Sissi.git
synced 2026-01-26 19:21:43 +00:00
[SIS-xxx] adding multiline support and allowing multiple words for orange sun doge command alternative
This commit is contained in:
@@ -50,16 +50,13 @@ public class OrangeSunDogeCommandAlternative implements CommandAlternative {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild, Message message) {
|
public boolean shouldExecute(UnParsedCommandParameter parameter, Guild guild, Message message) {
|
||||||
String contentStripped = message.getContentRaw();
|
return featureFlagService.isFeatureEnabled(imageGenerationFeatureConfig, guild.getIdLong());
|
||||||
String[] parameters = contentStripped.split(" ");
|
|
||||||
return parameters.length == 1 && featureFlagService.isFeatureEnabled(imageGenerationFeatureConfig, guild.getIdLong());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(UnParsedCommandParameter parameter, Message message) {
|
public void execute(UnParsedCommandParameter parameter, Message message) {
|
||||||
String contentStripped = message.getContentRaw();
|
String contentStripped = message.getContentRaw();
|
||||||
List<String> parameters = Arrays.asList(contentStripped.split(" "));
|
String inputText = commandRegistry.getCommandName(contentStripped, message.getGuild().getIdLong());
|
||||||
String inputText = commandRegistry.getCommandName(parameters.get(0), message.getGuild().getIdLong());
|
|
||||||
File triggeredGifFile = imageGenerationService.getOrangeSunDogeImage(inputText);
|
File triggeredGifFile = imageGenerationService.getOrangeSunDogeImage(inputText);
|
||||||
MessageToSend messageToSend = templateService.renderEmbedTemplate(DOGE_ORANGE_SUN_RESPONSE_TEMPLATE_KEY, new Object(), message.getGuildIdLong());
|
MessageToSend messageToSend = templateService.renderEmbedTemplate(DOGE_ORANGE_SUN_RESPONSE_TEMPLATE_KEY, new Object(), message.getGuildIdLong());
|
||||||
// template support does not support binary files
|
// template support does not support binary files
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ImageGenerationService {
|
public class ImageGenerationService {
|
||||||
@@ -20,7 +22,7 @@ public class ImageGenerationService {
|
|||||||
|
|
||||||
public File getOrangeSunDogeImage(String inputText) {
|
public File getOrangeSunDogeImage(String inputText) {
|
||||||
try {
|
try {
|
||||||
return httpService.downloadFileToTempFile(dogeOrangeSunUrl.replace("{1}", inputText));
|
return httpService.downloadFileToTempFile(dogeOrangeSunUrl.replace("{1}", URLEncoder.encode(inputText, StandardCharsets.UTF_8)));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new AbstractoRunTimeException(String.format("Failed to download orange doge image for url %s with error %s", inputText, e.getMessage()));
|
throw new AbstractoRunTimeException(String.format("Failed to download orange doge image for url %s with error %s", inputText, e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user