added current values to post post target

added support for custom setup steps for each feature
added mod mail category setup step
This commit is contained in:
Sheldan
2020-05-25 23:11:44 +02:00
parent 3714fd2582
commit 213f42ffbd
36 changed files with 342 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
package dev.sheldan.abstracto.core.config;
import dev.sheldan.abstracto.core.interactive.SetupStep;
import dev.sheldan.abstracto.core.service.FeatureValidator;
import java.util.Collections;
@@ -18,4 +19,5 @@ public interface FeatureConfig {
default List<FeatureValidator> getAdditionalFeatureValidators() { return Collections.emptyList(); }
default List<String> getRequiredEmotes() { return Collections.emptyList(); }
default List<FeatureMode> getAvailableModes() { return Collections.emptyList(); };
default List<SetupStep> getCustomSetupSteps() { return Collections.emptyList(); }
}

View File

@@ -0,0 +1,42 @@
package dev.sheldan.abstracto.core.interactive;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.Message;
import org.springframework.beans.factory.annotation.Autowired;
@Getter
@Setter
public abstract class AbstractConfigSetupStep implements SetupStep {
@Autowired
private InteractiveService interactiveService;
@Autowired
private TemplateService templateService;
@Autowired
private ChannelService channelService;
protected SetupExecution nextStep;
@Autowired
private InteractiveUtils interactiveUtils;
protected Runnable getTimeoutRunnable(Long serverId, Long channelId) {
return () -> {
interactiveUtils.sendTimeoutMessage(serverId, channelId);
};
}
protected boolean checkForExit(Message message) {
return message.getContentRaw().trim().equalsIgnoreCase("exit");
}
protected boolean checkForKeep(Message message) {
return message.getContentRaw().trim().equalsIgnoreCase("default");
}
}

View File

@@ -0,0 +1,12 @@
package dev.sheldan.abstracto.core.interactive;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Builder
public class EmptySetupParameter implements SetupStepParameter {
private Long previousMessageId;
}

View File

@@ -0,0 +1,29 @@
package dev.sheldan.abstracto.core.interactive;
import dev.sheldan.abstracto.core.service.ChannelService;
import dev.sheldan.abstracto.templating.service.TemplateService;
import net.dv8tion.jda.api.entities.TextChannel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
@Component
public class InteractiveUtils {
@Autowired
private TemplateService templateService;
@Autowired
private ChannelService channelService;
@Transactional
public void sendTimeoutMessage(Long serverId, Long channelId) {
String s = templateService.renderSimpleTemplate("setup_configuration_timeout");
Optional<TextChannel> channelOptional = channelService.getTextChannelInGuild(serverId, channelId);
channelOptional.ifPresent(channel -> {
channelService.sendTextToChannelNoFuture(s, channel);
});
}
}

View File

@@ -0,0 +1,14 @@
package dev.sheldan.abstracto.core.models.template.commands;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.TextChannel;
@Getter
@Setter
@Builder
public class SetupPostTargetMessageModel {
private String postTargetKey;
private TextChannel currentTextChannel;
}