mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-07 01:38:32 +00:00
added dynamic post target loading
fixed some templates of commands added fat jar maven config
This commit is contained in:
@@ -0,0 +1 @@
|
||||
abstracto.postTargets.moderation=joinLog,leaveLog,warnLog,kickLog,banLog,editLog,deleteLog
|
||||
@@ -0,0 +1 @@
|
||||
abstracto.postTargets.utility=suggestions
|
||||
@@ -0,0 +1 @@
|
||||
Accepts the given suggestion.
|
||||
@@ -0,0 +1 @@
|
||||
Accepts the given suggestion. Will post the suggestion again, with the given reason for acceptance, with the old text strike through and 'Accepted by' as a notice.
|
||||
@@ -0,0 +1 @@
|
||||
accept <suggestionId> [reason]
|
||||
@@ -0,0 +1 @@
|
||||
Rejects the given suggestion.
|
||||
@@ -0,0 +1 @@
|
||||
Rejects the given suggestion. Will post the suggestion again, with the given reason for rejection, with the old text strike through and 'Rejected by' as a notice.
|
||||
@@ -0,0 +1 @@
|
||||
reject <suggestionId> [reason]
|
||||
@@ -0,0 +1,31 @@
|
||||
package dev.sheldan.abstracto.core;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Getter
|
||||
@Setter
|
||||
@PropertySource("classpath:abstracto.properties")
|
||||
@ConfigurationProperties(prefix = "abstracto")
|
||||
public class PostTargetLoader {
|
||||
|
||||
private HashMap<String, String> postTargets = new HashMap<>();
|
||||
|
||||
public List<String> getPostTargetsAsList() {
|
||||
List<String> targets = new ArrayList<>();
|
||||
if(postTargets == null || postTargets.size() == 0) {
|
||||
return targets;
|
||||
}
|
||||
postTargets.values().forEach(s -> targets.addAll(Arrays.asList(s.split(","))));
|
||||
return targets;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class Ping implements Command {
|
||||
|
||||
public static final String PING_TEMPLATE = "ping";
|
||||
public static final String PING_TEMPLATE = "ping_response";
|
||||
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.abstracto.core.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.PostTargetLoader;
|
||||
import dev.sheldan.abstracto.core.exception.PostTargetException;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
@@ -25,9 +26,12 @@ public class PostTargetManagementBean implements PostTargetManagement {
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Autowired
|
||||
private PostTargetLoader postTargetLoader;
|
||||
|
||||
@Override
|
||||
public void createPostTarget(String name, AServer server, AChannel targetChannel) {
|
||||
if(!PostTarget.AVAILABLE_POST_TARGETS.contains(name)) {
|
||||
if(!postTargetLoader.getPostTargetsAsList().contains(name)) {
|
||||
throw new PostTargetException("PostTarget not found");
|
||||
}
|
||||
log.info("Creating post target {} pointing towards {}", name, targetChannel);
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface PostTargetService {
|
||||
CompletableFuture<Message> sendTextInPostTarget(String text, PostTarget target);
|
||||
CompletableFuture<Message> sendEmbedInPostTarget(MessageEmbed embed, PostTarget target);
|
||||
CompletableFuture<Message> sendTextInPostTarget(String text, String postTargetName, Long serverId);
|
||||
CompletableFuture<Message> sendEmbedInPostTarget(MessageEmbed embed, String postTargetName, Long serverId);
|
||||
CompletableFuture<Message> sendEmbedInPostTarget(MessageEmbed embed, PostTarget target);
|
||||
CompletableFuture<Message> sendTextInPostTarget(String text, String postTargetName, Long serverId);
|
||||
CompletableFuture<Message> sendEmbedInPostTarget(MessageEmbed embed, String postTargetName, Long serverId);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,23 @@
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<artifactId>executable</artifactId>
|
||||
|
||||
<properties>
|
||||
<start-class>dev.sheldan.abstracto.Application</start-class>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
Reference in New Issue
Block a user